简体   繁体   English

仿射变换矩阵

[英]Affine Transformation Matrix

I'm trying to perform image stabilization on a set of images. 我正在尝试对一组图像进行图像稳定。 I have identified matching pairs of corner points in each image and am trying to calculate the affine transformation matrix for each set of matching pairs (source vs. destination). 我已经确定了每个图像中角点的匹配对,并正在尝试为每对匹配对(源与目标)计算仿射变换矩阵。 When I do this, though, using a least squares method, the resulting transformation matrix produces images that are not stabilized. 但是,当我这样做时,使用最小二乘法,生成的变换矩阵会生成不稳定的图像。 I am following this process: 我正在执行以下过程:

source_points = [[219, 187], [221, 387], [347, 31], [135, 311], [296, 615], [86, 417]]
dst_points = [[221, 187], [222, 387], [348, 30], [137, 310], [299, 615], [88, 417]]

transform_mat, res, rank, s = np.linalg.lstsq(source_points, dst_points)

#looping through all dst_coordinates in a blank array of size = source image
transformed_coor = np.dot(transform_mat,dst_coordinate)

After looping through the coordinates in the blank array, I grab the interpolated value of the transformed_coor from the source image and place that value at the dst_coordinate in the blank array. 在空白数组中的坐标循环之后,我从源图像中获取了transformd_coor的插值,并将该值放在空白数组中的dst_coordinate处。 When the process completes I get a transformed image but it is not stabilized when I compare it with the source image. 该过程完成后,我得到了一个转换后的图像,但是当我将其与源图像进行比较时,它并不稳定。

Is this process correct? 这个过程正确吗? Am I missing a step? 我错过了一步吗?

I think your point correspondences source_points and dst_points are not matching well. 我认为您的点对应source_points和dst_points匹配得不好。 For this very input I computed the affine transformation matrix 对于这个输入,我计算了仿射变换矩阵

T = [0.9997   -0.0026   -0.9193
     0.0002    0.9985    0.7816
          0         0    1.0000]

which leads to individual transformation errors (Euclidean distance) of 导致个体的转换误差(欧几里得距离)

errors = [0.7592    1.0220    0.2189    0.6964    0.4003    0.1763]

for the 6 point correspondences. 6点对应。 Those are relatively large, especially when considering the distances between source_points and dst_points of 这些相对较大,尤其是在考虑以下情况的source_point和dst_points之间的距离时:

move_dist = [2.0000    1.0000    1.4142    2.2361    3.0000    2.0000] 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM