我有一个二值图像 lu,当我旋转图像时,图像 lu 的大小会发生变化,但我需要保留图像的大小:
m=2048;
n=3072;
ODcenter =1.0e+03 *[2.0345 0.9985]
OD=ODcenter ;
X=zeros(m,n); %% m,n is size of image
t = 0:.1:2*pi;
ODradius = norm(ODcenter(2) - ODcenter(1)) / 2;
xm2 = round(2*ODradius*cos(t)+OD(1));
ym2 = round(2*ODradius*sin(t)+OD(2));
imCircleAlphaData2 = roipoly(X,xm2,ym2);
figure; imshow(imCircleAlphaData2);
lu=imCircleAlphaData2;
mask1 = true(size(lu)); %# Create a matrix of true values the same size
mask1(ODcenter(2):end,:) = false; %# Set the lower half to false
lu(~mask1) = 0; %# Set all elements in lu corresponding to mask 1==0
mask2 = true(size(lu));
mask2(:,ODcenter(1):end) = false; %# Set the right of the upper half to false
lu(~mask2) = 0; %# Set all elements in lu corresponding mask 2==0
figure;
imshow(lu); % shows left upper
lurot= imrotate(lu,45);
figure,imshow(lurot)
lurot 和 lu 的大小不同。即使旋转后图像的某些部分会被裁剪,我如何保留图像的大小