如何在两个图像中找到对应的点? [英] How to find corresponding points in two images?

查看:181
本文介绍了如何在两个图像中找到对应的点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在进行图像配准.我正在使用OpenCV.我有两个图像I1(参考图像),I2(当前图像).我确定它们之间的仿射运动,然后扭曲I1以查看其与当前图像I2对齐的程度.此时,我有3个图像I1,I1'(失真)和I2.

I am working with image registration. I am using OpenCV. I have two images I1(reference image), I2(current image). I determine Affine motion between them then warp I1 to see how much it aligns with the current image I2. At this point I have 3 images I1, I1'(distorted) and I2.

现在,我需要在当前图像I2上设置4个点(这是为了在GUI上显示),并且需要在初始参考图像I1上找到对应的4个点(在应用运动之前). GUI突出显示了一些功能差异,需要在I1和I2上来回切换,以便用户理解差异.

Now I need to set 4 points on the current image I2 ( this is for display purpose on a GUI) and need to find corresponding 4 points on the initial reference image I1 (prior to applying the motion). The GUI highlights some feature difference and needs to toggle back and forth on I1 and I2 for the user to understand the difference.

这四个点基本上是图像内的任意矩形.例如:

the four points are basically an arbitrary rectangle within the image. For example:

cv::Point P1, P2, P3, P4;
P1.x = I2.cols / 4;
P1.y = I2.rows / 4;
P2.x = I2.cols * 3 / 4;
P2.y = I2.rows / 4;
P3.x = I2.cols * 3 / 4;
P3.y = I2.rows * 3 / 4;
P4.x = I2.cols / 4;
P4.y = I2.rows * 3 / 4;

我需要在参考图像I1上找到P1,P2,P3,P4的对应点. 关于如何使用OpenCV做到这一点的任何想法?还是其他方式?

I need to find corresponding points of P1, P2, P3, P4 on reference image I1. Any idea on how can I do that using OpenCV? Or any other way?

推荐答案

您正在编写仿射矩阵,将l1扭曲为l2.

You are writing that you have affine matrix, that warps l1 to l2.

所有您需要的是通过

All you need is to invert the affine transformation M via invertAffineTransform to get matrix M'

然后将这个2x3矩阵M'应用于点:

And then apply this 2x3 matrix M' to the points:

(pseudocode)

P1_onL1 = M' * [P1.x, P1.y, 1].t()

.t()表示转置,因此您需要将矩阵乘以列向量.

where .t() means transpose, so you need to multiply matrix by a column vector.

这篇关于如何在两个图像中找到对应的点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆