How to close boundary of a circular object in binary image
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
CW Hsu
el 29 de Nov. de 2022
Comentada: CW Hsu
el 9 de Dic. de 2022
Thank you all for being here.
I have an image below
the outer boundary is not closed. So it would be a problem when I calculate area of this bubble.
How can I close the boundary of circular object in image above image automatically?
0 comentarios
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 30 de Nov. de 2022
Try this, where mask is your binary image
mask = bwconvhull(mask, 'union');
props = regionprops(mask, 'Area', 'EquivDiameter');
area = props.Area
diameter = props.EquivDiameter
2 comentarios
Image Analyst
el 1 de Dic. de 2022
You can use the 'objects' option but keep in mind that if the curves are too far apart it will consider them as two separate blobs. So two C shapes might end up as two solid D shapes. Only if their convex hulls overlap would they be considered a single blob. And then you might get something like your bottom image. So you'd have to call bwconvhull a second time to get a convex shape.
Another option would be to use dbscan to identify which pixels are close to each other. You specify that closeness distance. So this essentially labels each group of blobs with a single ID number. Then you can use ismember to extract each group one at a time, and then use the 'union' option since all pixels in the image now belong to a single group. Then repeat for all groups in the image. I'm attaching a demo I created of dbscan. See Wikipedia if you don't know what dbscan is.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!