【问题标题】:Affine Transformation Matrix仿射变换矩阵
【发布时间】:2016-03-29 20:39:13
【问题描述】:

我正在尝试对一组图像执行图像稳定。我已经确定了每个图像中匹配的角点对,并试图为每组匹配对(源与目标)计算仿射变换矩阵。但是,当我这样做时,使用最小二乘法,生成的变换矩阵会产生不稳定的图像。我正在关注这个过程:

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)

遍历空白数组中的坐标后,我从源图像中获取transformed_coor 的插值,并将该值放在空白数组中的dst_coordinate。该过程完成后,我得到一个转换后的图像,但当我将其与源图像进行比较时,它并不稳定。

这个过程正确吗?我错过了一步吗?

【问题讨论】:

  • 你怎么知道正确答案是什么?你能举一个输入和期望输出的例子吗?
  • 到目前为止,我正在对生成的“稳定”图像与原始图像进行目视检查。另一种选择是查看源和稳定之间的差异,并确定 % 错误(尽管这可能没有那么有用,因为我没有 % 错误的阈值)
  • 您的转换错误是什么?将 transform_mat 映射到两个集合 source_points 和 dst_points 的效果如何? transform_mat * [219, 187] 应该给出类似 [221,187] 的内容。

标签: python matrix transformation affinetransform coordinate-transformation


【解决方案1】:

我认为您的点对应 source_points 和 dst_points 不匹配。对于这个输入,我计算了仿射变换矩阵

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

导致个体变换误差(欧几里得距离)的

errors = [0.7592    1.0220    0.2189    0.6964    0.4003    0.1763]

对于 6 点对应关系。这些都比较大,尤其是考虑到 source_points 和 dst_points 之间的距离时

move_dist = [2.0000    1.0000    1.4142    2.2361    3.0000    2.0000] 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-06
    • 2020-08-11
    • 2011-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多