matlab - 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;
解决方案
解决了它,imwarp 可以返回一个 im2dref 对象,您可以将其与 worldToIntrinsic 一起使用
[img2t, ref] = imwarp(img2, invert(tform));
[transformedPointsX, transformedPointsY] = worldToIntrinsic(ref, points(:, 1), points(:, 2));
推荐阅读
- android - 我们可以将文件从 Android 共享存储复制到应用程序的文件夹吗?
- javascript - 为什么我的 javascript 代码忽略了 if?
- mysql - 如何将值映射到mysql中的sinle id?
- python - 如何在 django 中删除项目?
- node.js - 在子进程中一次运行 multipul 文件
- sql - 获取所有组中最大计数分组结果的记录
- javascript - 在 d3 条形图中跳过 x 轴上的 NULL 标签
- pine-script - 在“情节”上得到:“Pine 无法确定系列的参考长度”错误
- sabre - Saber - 申请虚空机票需要多少步骤?
- bash - curl -d json 里面的 var 无效