I want to transform an trapez into a square (fitgeotrans)
조회 수: 4 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Asvin Kumar
2019년 10월 31일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!