Emania

correct.m

Apr 15th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.60 KB | None | 0 0
  1. input_path = 'img.jpg';
  2. save_path = 'img_processed.jpg';
  3.  
  4. img = imread(input_path);
  5. if size(img,3)==3
  6.    img = rgb2gray(img);
  7. end
  8.  
  9. movingPoints = [19 103; 2353 337; 2391 1640;32 1925]; %coordinate of distorted corners
  10. fixedPoints=[0 0;2500 0;2500 1500;0 1500]; %coordinate of image's corners
  11. TFORM = fitgeotrans(movingPoints,fixedPoints,'projective');
  12. R=imref2d(size(img),[1 size(img,2)],[1 size(img,1)]);
  13. imgTransformed=imwarp(imread(input_path),TFORM,'OutputView',R);
  14. imgTransformed = imgTransformed(1:1500, 1:2500, :);
  15. figure, imshow(imgTransformed);
  16. imwrite(imgTransformed, save_path)
  17. 'Done'
Advertisement
Add Comment
Please, Sign In to add comment