任意の点を中心に指定したサイズでトリミングを行いたい
10 views (last 30 days)
Show older comments
添付している1枚目(student.jpg)の画像があった時に、2枚目(student_all.jpg)の画像のようにトリミングを行いたいと考えています。トリミングの方法を「原点を中心にトリミングをしたい」と思い、原点は、student.jpgの(376,687)に位置し、原点を中心に欲しいサイズである408×408にトリミングしたいのですが、どのようにすればできるのかがわかりません。
0 Comments
Accepted Answer
Akira Agata
on 28 Dec 2020
imcrop 関数を使って、以下のようにするとトリミングできます。
I = imread('student.jpg');
% 中心とcropするサイズ
cent = [376, 687];
sz = [408, 408];
% [x, y, width, height] 形式のベクトルを作成
rect = [cent - sz./2, sz];
% crop処理を実施
Icrop = imcrop(I,rect);
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!