I want to transform an trapez into a square (fitgeotrans)

6 vues (au cours des 30 derniers jours)
Dario Carosella
Dario Carosella le 28 Oct 2019
Hi
I'm trying to transform an trapez into a square:
4pointTrans.png
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:
pic1.png
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.

Réponses (1)

Asvin Kumar
Asvin Kumar le 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.

Catégories

En savoir plus sur Mathematics and Optimization dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by