フィルターのクリア

How to crop required ROI from an image?

38 ビュー (過去 30 日間)
Revathi S
Revathi S 2018 年 9 月 23 日
コメント済み: Image Analyst 2018 年 9 月 29 日
% code
h = impoly(gca,[188,30; 189,142; 93,141; 13,41]);
api = iptgetapi(h);
fcn = makeConstrainToRectFcn('impoly',get(gca,'XLim'),get(gca,'YLim'));
api.setPositionConstraintFcn(fcn);
position = wait(h);
a=imcrop(I,[250 91;251 203;155 202;75 102]]);
imshow(I);
end
I am working on medical image processing.
I need to crop eye only from face & position is not constant for all images.
so i use polygonal ROI.
but it shows error.
  2 件のコメント
Image Analyst
Image Analyst 2018 年 9 月 23 日
Read this link so you know how to format your code.
Revathi S
Revathi S 2018 年 9 月 23 日
Ok. thanks Modified

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2018 年 9 月 23 日
Call imcrop() with no arguments if the coordinates are not the same from image to image. This will let the user interactively select the box.
  2 件のコメント
Revathi S
Revathi S 2018 年 9 月 23 日
Imcrop() deals with rectangular boundary.
My ROI is not a rectangular shape (ie, Eye )
It contain some unwanted portion while cropping.
Image Analyst
Image Analyst 2018 年 9 月 29 日
Try this freehand masking demo.

サインインしてコメントする。

その他の回答 (1 件)

Revathi S
Revathi S 2018 年 9 月 29 日
if true
e = roipoly(I);
ROI=zeros(size(I,1),size(I,2));
NONROI=zeros(size(I,1),size(I,2));
int16(i);
int16(j);
for i=1:size(I,1)
for j=1:size(I,2)
if e(i,j)==1
ROI(i,j)=I(i,j);
ROI(i,j)=1;
end
end
end
Code for Croping Required ROI

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by