How can I extract a portion of an image specified by mask generated from a ROI in Image Processing Toolbox 7.3 (R2011b)?
Show older comments
I have an image where I have specified a region of interest (ROI) using functions such as IMELLIPSE or IMFREEHAND. I would like to extract the part of the image contained within the region specified by such a function.
Accepted Answer
More Answers (1)
michael scheinfeild
on 26 Feb 2019
if you have some mask (nr*nc image)use find where the indexes are 1 in the mask only for rectangular mask !
okind=find(Mask>0);
[ii,jj]=ind2sub(size(Mask),okind);
ymin=min(ii);ymax=max(ii);xmin=min(jj);xmax=max(jj);
imCropped=imcrop(Y,[xmin,ymin,xmax-xmin+1,ymax-ymin+1]);
Categories
Find more on Region and Image Properties 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!