I want to transform an trapez into a square (fitgeotrans)
6 views (last 30 days)
Show older comments
Hi
I'm trying to transform an trapez into a square:
RGB = imread('4pointTrans.png');
imshow(RGB);
% define 4 source point
src = [284 95; 594 95; 722 594; 156 594];
% define 4 target points
trg = [156 95; 722 95; 722 594; 156 594];
tform1 = fitgeotrans(trg,src, 'projective');
I_rct2 = imwarp(RGB, tform1);
figure, imshow(I_rct2);
But when I use this code matlab make this:
And when I change the src and trg in the fitgeotrans() function it works... But why? The Function defined that first comes the moving points and then the source...
Thanks for helping.
0 Comments
Answers (1)
Asvin Kumar
on 31 Oct 2019
The fitgeotrans function transforms the control point pairs in the movingPoints argument to the control point pairs in the fixedPoints argument.
The following line of code would then produce the desired output in your case.
tform1 = fitgeotrans(src, trg, 'projective');
This is because the ‘src’ control point pairs belong to the trapezium which you want to transform into a square to which the ‘trg’ control point pairs belong.
0 Comments
See Also
Categories
Find more on Mathematics and Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!