不同程度的偏斜/剪切图像

时间:2013-10-27 23:31:35

标签: matlab image-processing computer-vision

我想知道是否有人可以检查我的代码是否有图像的偏斜/剪切。它会扭曲图像,但效率不高。似乎某些东西不能正常工作。只是给了我一个白色歪斜的图像

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);

非常感谢。

1 个答案:

答案 0 :(得分:0)

您应该考虑使用shear matrix来加速剪切