【发布时间】: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