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

6 visualizaciones (últimos 30 días)
Dario Carosella
Dario Carosella el 28 de Oct. de 2019
Respondida: Asvin Kumar el 31 de Oct. de 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.

Respuestas (1)

Asvin Kumar
Asvin Kumar el 31 de Oct. de 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.

Categorías

Más información sobre Mathematics and Optimization en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by