MATLAB: How to construct a circular shape on bw image that contains all the shapes in the image

image analysisimage processingImage Processing Toolbox

I have to define a circular region on a BW image that circumscribe all the elements of the matrix with value equal to 1, I want also to split that region in 4 quadrants and count the number of elements equal to 1 contained in each quadrant – for the application I want to compute the ratio between the number of elements with value = 1 and the total number of elements for each quadrant.

Best Answer

Use bwconvhull() to produce a mask that circumscribes all the regions in your binary image. Then use regionprops() to get the centroid row and column. Once you know that, you can simply use sum() with indexing to count the pixels in either binary image.
Related Question