-1
我正在嘗試在像素上逐像素地對圖像進行平移,歐幾里得,相似度,仿射和投影轉換。我的程序的輸入是圖像名稱和變換矩陣。按像素進行2D圖像轉換
這是我的代碼
function imagetrans(name, m)
Image = imread(name);
[rows, cols] = size(Image);
newImage(1:rows,1:cols) = 1;
for row = 1 : rows
for col = 1 : cols
if(Image(row,col) == 0)
point = [row;col;1];
answer = m * point;
answer = int8(answer);
newx = answer(1,1);
newy = answer(2,1);
newImage(newx,newy) = 0;
end
end
end
imshow(newImage);
end
現在我只測試一個平移矩陣。
matrix =
1 0 7
0 1 2
0 0 1
我在做什麼錯?
謝謝!我會嘗試這個,..我是新來的Matlab,我不知道有一個調試器。感謝您的更新 – Debbie
這也工作!謝謝 – Debbie