在Python中规范化点,以便距离原点的RMS距离为sqrt2

2024-07-04 16:29:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我想实现DLT算法,我有6个对象点(X,Y,Z,1).T和6个图像点(u,v,1).T,它们是对象点到图像平面的投影

因此,在实现DLT之前,我必须规范化数据

更具体地说,我发现我必须做到以下几点: 二维图像点应标准化,以便其质心位于原点,且其与原点的均方根距离为sqrt(2)

你知道我如何用python实现吗


Tags: 数据对象图像算法距离sqrt规范化平面
1条回答
网友
1楼 · 发布于 2024-07-04 16:29:46

为两张图像(一张原始图像和另一张扭曲图像)获取6个图像点,然后:

x1 = np.array([202,202,500,523,530,522])
y1 = np.array([459,473,403,403,405,434])
x2 = np.array([283,285,526,544,552,550])
y2 = np.array([482,494,371,367,365,392])
img1 = np.column_stack((x1,y1))
img2= np.column_stack((x2,y2))`

def normalise(img):
    '''
    input:img = image points that we want to normalize
    return:Tr = Transformation that normalises the points
    normalised_points = Points normalise by Tr
    '''
    s = np.sqrt(2)/((1/25)*np.sum((np.sqrt(abs(img - np.mean(img,axis=0))**2))))
    m = np.mean(img,0)
    normalised_points = np.zeros((25,3))
    Tr = np.array([[s, 0, m[0]], [0, s, m[1]], [0, 0, 1]])
    for i in range(img.shape[0]):
        normalised_points[i][0] = s*img[i][0] + m[0]
        normalised_points[i][1] = s*img[i][1] + m[1]
        normalised_points[i][2] = 1
    return Tr, normalised_points

Tr1,normalised_X = normalise(img1)

Ref

相关问题 更多 >

    热门问题