1
由於某種原因,默認情況下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)
我想你混淆了「軸」命令「擴展數據」命令。 [史蒂夫博士關於Matlab圖像處理](http://blogs.mathworks.com/steve/2006/07/07/spatial-transformations-translation-confusion/)有一些很好的例子。 – Maurits
文章看起來不會對我說新話。我仍然不明白,如何在所有情況下進行轉換。注意:我不想正確地在屏幕上繪製圖像,我想讓它在內存中正確轉換。 –