首页 > 解决方案 > Matlab - 如何用扭曲的图像变换点

问题描述

我有两张相同的图片,但一张已翻译。我的代码需要找到这些之间的转换,但我已经实现了。

我现在有一个可视化的问题,我想转换两个图像,使它们处于相同的角度,绘制两个图像,然后在两个图像上绘制相同的点集,但我不知道如何计算出相对坐标校正后的第二张图像上的点。

我的代码如下:

% tform is an Affine2D Transform between img1 and img2
% img1 and img2 are rgb images
% points is a 10x2 matrix containing a set of points on img1
figure();
subplot(1, 2, 1);
hold on;
imshow(img1);
plot(points(:, 1), points(:, 2), '.r')
hold off;
transformedPoints = [Don't Know what goes here...]
img2t = iwarp(img2, invert(tform))
subplot(1, 2, 2);
hold on;
imshow(img2t);
plot(transformedPoints(:, 1), transformedPoints(:, 2), '.r')
hold off;

标签: matlabimage-processingcomputer-visioncoordinatestransformation

解决方案


解决了它,imwarp 可以返回一个 im2dref 对象,您可以将其与 worldToIntrinsic 一起使用

[img2t, ref] = imwarp(img2, invert(tform));
[transformedPointsX, transformedPointsY] = worldToIntrinsic(ref, points(:, 1), points(:, 2));

推荐阅读