由于某种原因imtransform
,函数默认忽略翻译部分。
如果我像手册中所说的那样添加额外的空间XData
,我将只处理简单的情况(即仅翻译)。YData
那么,如何在 Matlab 中应用全功能仿射变换呢?
I = imread('cameraman.png');
imshow(I);
% does not translate
xform = [1 2 0; 2 1 0; 100 0 1];
T = maketform('affine',xform);
I2 = imtransform(I,T);
figure, imshow(I2)
% translates but cuts some portion of an image
xform = [1 2 0; 2 1 0; 100 0 1];
T = maketform('affine',xform);
I2 = imtransform(I,T,'XData',[1 size(I,2)+xform(3,1)],'YData',[1 size(I,1)+xform(3,2)]);
figure, imshow(I2)