射影変換のやり方を知りたい
53 views (last 30 days)
Show older comments
前回、https://jp.mathworks.com/matlabcentral/answers/1842433-?s_tid=srchtitle
にて射影変換をご教授いただいたのですが、座標を入れてもうまくいきません。
というのも、画像を抜き出して正面にするのではなく、元画像を加工するような形になってしまったからです。
にある、「出発」部分のみを切り出し、正面にするプログラムを組みたいのですが、ご教授いただけないでしょうか。
0 Comments
Accepted Answer
Hernia Baby
on 16 Nov 2022
手前味噌ですが、自分の回答を参考にお答えします
---
まずは画像を読み込みます
I = imread('test.png');
imshow(I)
次に抽出したい座標をとりましょう
% [xi,yi] = getpts
x = [48, 422, 39, 429]';
y = [160, 66, 246, 176]';
originalPoints = [x,y];
そして写像変換したい座標を決めます
いただいたリンクを参考にしました
ow = floor(norm(originalPoints(2,:) - originalPoints(1,:)));
oh = floor(norm(originalPoints(3,:) - originalPoints(1,:)));
fixedPoints = [0, 0; ow, 0; 0, oh; ow, oh];
tform = fitgeotrans(originalPoints, fixedPoints, 'projective');
RA = imref2d([size(I,1) size(I,2)], [1 ow], [1 oh]);
[out,r]= imwarp(I, tform,'OutputView', RA);
見てみましょう
imshow(out,r)
axis off
More Answers (0)
See Also
Categories
Find more on 領域とイメージのプロパティ 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!