How to get a rectangular subimage from regionprops(Image,'BoundingBox') in Matlab?

后端 未结 2 2013
既然无缘
既然无缘 2020-12-29 01:02

I have some particles that I\'ve identified in a larger image, and need to parse into smaller images for each particle. I\'ve used the regionprops \'BoundingBox\' function,

2条回答
  •  余生分开走
    2020-12-29 01:39

    The parameters returned by regionprops are [y,x,width,height] in matrix coordinates (see also "unexpected Matlab".

    Thus, to extract the rectangle, you write:

    subImage = I(round(s(1).BoundingBox(2):s(1).BoundingBox(2)+s(1).BoundingBox(4)),...
           round(s(1).BoundingBox(1):s(1).BoundingBox(1)+s(1).BoundingBox(3)));
    

提交回复
热议问题