I want to transform an trapez into a square (fitgeotrans)
6 ビュー (過去 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!