校正功能以平衡深度

发布于 2025-02-05 19:50:41 字数 1820 浏览 2 评论 0原文

我有一个深度图像,形状为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,计算了xy轴的旋转角度,并应用了旋转,如下所示:

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:

enter image description 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

假装爱人 2025-02-12 19:50:42

正如@yvesdaoust的建议,减去双线性模型已经解决了这个问题:

    def corr_func(self, arr):
        """
        Empirical Values
        """
        self.y_correc = 0.0 #- 0.5
        self.x_correc = + 4.0
        
        if(self.corr_array is None):
            self.corr_array = np.zeros((arr.shape), dtype=np.int16)
            r, c = arr.shape

            for i in range(r):
                for j in range(c):
                    self.corr_array[i, j] = floor(i*self.x_correc + j*self.y_correc)
                        
        arr = arr.astype(np.int16)
        arr += self.corr_array
        arr[arr<0]=0
        arr = arr//2
        arr = arr.astype(np.uint8)
        return arr

As @YvesDaoust suggested, subtracting a Bilinear Model has solved this problem:

    def corr_func(self, arr):
        """
        Empirical Values
        """
        self.y_correc = 0.0 #- 0.5
        self.x_correc = + 4.0
        
        if(self.corr_array is None):
            self.corr_array = np.zeros((arr.shape), dtype=np.int16)
            r, c = arr.shape

            for i in range(r):
                for j in range(c):
                    self.corr_array[i, j] = floor(i*self.x_correc + j*self.y_correc)
                        
        arr = arr.astype(np.int16)
        arr += self.corr_array
        arr[arr<0]=0
        arr = arr//2
        arr = arr.astype(np.uint8)
        return arr
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文