【问题标题】:How to find a point on image after rotation?旋转后如何在图像上找到一个点?
【发布时间】:2015-10-14 14:08:40
【问题描述】:

图像上的点(x,y)在旋转后需要位于同一图像上。我使用了 imrotate、imtransform 和 imwarp 来旋转图像(下面的代码显示了 imwarp 的实现),但似乎没有一个对我有用。输出的旋转图像大于原始图像。任何人都可以建议如何在输出旋转图像上定位同一点。

close all;
I=imread('P.png');
x=339;
y=317;

subplot(2,2,1);
imshow(I),title('Original Image');    
hold on;
plot(x,y,'ro');
hold off;
theta=5;
tform = affine2d([cosd(theta) -sind(theta) 0;sind(theta) cosd(theta) 0; 0 0 1])
RI = imwarp(I,tform);
[x1,y1]=transformPointsForward(tform,x,y);
subplot(2,2,2);
imshow(RI),title('Rotated Image');    
hold on;
plot(x1,y1,'ro');
hold off;

尽管如果旋转图像与原始图像具有相同大小,则代码有效。但在我的情况下,它会导致原始图像的裁剪。我已经能够在各种论坛上找到这个问题的答案,但似乎没有一个对我有用。请回答。

【问题讨论】:

    标签: matlab image-processing rotation affinetransform


    【解决方案1】:

    像这样拨打imwarp

    [RI, ref] = imwarp(I,tform);
    

    refimref2d 类型的空间引用对象,它包含输出图像坐标系与“世界坐标系”的关系,在这种情况下,它是输入图像的坐标系。然后你可以像这样解释翻译:

    [x1,y1]=transformPointsForward(tform,x,y);
    x1 = x1 - ref.XWorldLimits(1);
    y1 = y1 - ref.YWorldLimits(1);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-24
      • 2016-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多