校正功能以平衡深度
我有一个深度图像,形状为11 x 23
,我确实想使用四个角度的深度相同在此处的图中显示了值:
总如下:
def corr_func(arr):
"""
Function: corr_func, linear correction of discrete depth values.
---
Parameters:
@param: arr, ndarray, depth image to be corrected.
---
@return: arr, ndarray, corrected depth image.
"""
c_00 = int(arr[0][0])
c_01 = int(arr[0][-1])
c_10 = int(arr[-1][0])
y_corr = (c_01 - c_00)/arr.shape[1]
x_corr = (c_10 - c_00)/arr.shape[0]
print("x_corr = {}, y_corr = {}".format(x_corr, y_corr))
r, c = arr.shape[:2]
for i in range(r):
for j in range(c):
corr = math.floor(j*y_corr + i*x_corr)
arr[i,j] -= corr
return arr
我的第一个想法是计算拐角之间的差异,并将每个单元格的差异 校正值累积并使极端角值比应有的高。
编辑:
遵循@christophrackwitz的建议 我将深度值视为z
,计算了x
和y
轴的旋转角度,并应用了旋转,如下所示:
def corr_func(arr):
"""
Function: corr_func, non-linear correction of discrete depth values.
---
Parameters:
@param: arr, ndarray, depth image to be corrected.
---
@return: arr, ndarray, corrected depth image.
"""
c_00 = int(arr[0][0])
c_01 = int(arr[0][-1])
c_10 = int(arr[-1][0])
alpha = atan2((c_01 - c_00), arr.shape[1])
beta = atan2((c_10 - c_00), arr.shape[0])
arr = arr * cos(alpha) * cos (beta)
arr = arr.astype(np.uint8)
return arr
结果:结果似乎比线性校正更好,但如果可能的话,仍在寻找更好的结果。
您能向我建议一种更好的更正方法吗?提前致谢。
I have a depth image with a shape of 11 x 23
, and I do want to balance the depth in all cells using the fact that the depth in the four corners is the same, the values are shown in the drawing here:
My first idea was to calculate the difference between the corners and to sum that difference for each cell as follows:
def corr_func(arr):
"""
Function: corr_func, linear correction of discrete depth values.
---
Parameters:
@param: arr, ndarray, depth image to be corrected.
---
@return: arr, ndarray, corrected depth image.
"""
c_00 = int(arr[0][0])
c_01 = int(arr[0][-1])
c_10 = int(arr[-1][0])
y_corr = (c_01 - c_00)/arr.shape[1]
x_corr = (c_10 - c_00)/arr.shape[0]
print("x_corr = {}, y_corr = {}".format(x_corr, y_corr))
r, c = arr.shape[:2]
for i in range(r):
for j in range(c):
corr = math.floor(j*y_corr + i*x_corr)
arr[i,j] -= corr
return arr
This approach didn't work well as the correction value accumulates and makes the extreme corner value higher than it should be.
Edit:
Following the kind suggestion of @ChristophRackwitz
I have treated the depth values as z
, calculated the rotation angles on X
, and Y
axis, and applied the rotation as follows:
def corr_func(arr):
"""
Function: corr_func, non-linear correction of discrete depth values.
---
Parameters:
@param: arr, ndarray, depth image to be corrected.
---
@return: arr, ndarray, corrected depth image.
"""
c_00 = int(arr[0][0])
c_01 = int(arr[0][-1])
c_10 = int(arr[-1][0])
alpha = atan2((c_01 - c_00), arr.shape[1])
beta = atan2((c_10 - c_00), arr.shape[0])
arr = arr * cos(alpha) * cos (beta)
arr = arr.astype(np.uint8)
return arr
The results seem to be better than the linear correction, but still looking for better results if possible.
Can you please suggest to me a better correction approach? thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如@yvesdaoust的建议,减去双线性模型已经解决了这个问题:
As @YvesDaoust suggested, subtracting a Bilinear Model has solved this problem: