2

假设我有图像中某个点的 XY 坐标。

然后,我使用“相似性”优化对此图像执行非变形配准。

现在我想计算与图像中同一点对应的新 XY 坐标(注册后)。

我敢打赌,应该有一种方法可以通过使用 tform / 空间参考对象 / 类似的东西来做到这一点......

有谁知道如何做到这一点?

4

1 回答 1

2

给定一个在 MATLAB 中表示为 affine2d 对象的刚性变换,您可以通过调用 affine2d 的transformPointsForward方法计算与变换后图像的输出空间中的位置相对应的新 XY 点。

例如:

fixed  = imread('cameraman.tif');
theta = 20;
S = 2.3;
tform = affine2d([S.*cosd(theta) -S.*sind(theta) 0; S.*sind(theta)     S.*cosd(theta) 0; 0 0 1]);
moving = imwarp(fixed,tform);
moving = moving + uint8(10*rand(size(moving)));
tformEstimate = imregcorr(moving,fixed);
[x_out,y_out] = transformPointsForward(tformEstimate,10,20)

另外,如果你想在相反的方向(从输出空间到输入空间)进行变换,你可以类似地使用transformPointsInverse方法。

[u_out,v_out] = transformPointsInverse(tformEstimate,x_out,y_out)
于 2015-07-27T20:22:13.680 回答