在旋转图像后,需要将图像上的点(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;
虽然如果旋转后的图像与原始图像大小相同,代码可以正常工作。但在我的情况下,这会导致原始图像被裁剪。我已经在各种论坛上找到了这个问题的答案,但似乎没有一个适用于我。请给出答案。