我想知道是否有人可以检查我的图像倾斜/剪切代码。它会扭曲图像,但效率不高。似乎有些东西不能正常工作。它只是给了我一个白色歪斜的图像
clear all
img1 = imread('image.jpg');imshow(img1);
[m,n,p]=size(img1);
NumPixels = n*m;
[Points(1,:) Points(2,:)] = ind2sub([n m],1:NumPixels);
thetas = 30;
sx = 1/tand(thetas);
Sx = [1 sx; 0 1];
Points_tform = round(Sx * Points);
n_t = max(Points_tform(1,:));
m_t = max(Points_tform(2,:));
img_t = zeros(n_t,m_t);
for k = 1:length(Points)
try img_t(Points_tform(2,k),Points_tform(1,k)) = img1(Points(2,k),Points(1,k),1);
catch
a=1;
end
end
figure;
imshow(img_t);
非常感谢。