Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- input_path = 'img.jpg';
- save_path = 'img_processed.jpg';
- img = imread(input_path);
- if size(img,3)==3
- img = rgb2gray(img);
- end
- movingPoints = [19 103; 2353 337; 2391 1640;32 1925]; %coordinate of distorted corners
- fixedPoints=[0 0;2500 0;2500 1500;0 1500]; %coordinate of image's corners
- TFORM = fitgeotrans(movingPoints,fixedPoints,'projective');
- R=imref2d(size(img),[1 size(img,2)],[1 size(img,1)]);
- imgTransformed=imwarp(imread(input_path),TFORM,'OutputView',R);
- imgTransformed = imgTransformed(1:1500, 1:2500, :);
- figure, imshow(imgTransformed);
- imwrite(imgTransformed, save_path)
- 'Done'
Advertisement
Add Comment
Please, Sign In to add comment