bwboundaries mistaking holes for children
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have the following binary image that I trying to use bwboundaries.
Simple image from a threshold operation
obstacles = ~bwareaopen(majorityFilter,10000);
imshow(obstacles)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/955280/image.jpeg)
Total of 10 obstacles correct? When I apply bwboundaries, I'm getting 13 obstacles.
[currPoly,L]=bwboundaries(logical(~obstacles),8,'holes');
currPoly =
13×1 cell array
{ 553×2 double}
{ 565×2 double}
{ 574×2 double}
{ 747×2 double}
{ 855×2 double}
{ 880×2 double}
{1242×2 double}
{ 484×2 double}
{ 609×2 double}
{ 700×2 double}
{ 257×2 double}
{ 21×2 double}
{ 13×2 double}
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/955285/image.jpeg)
Any idea why this is happening?
0 commentaires
Réponses (2)
Walter Roberson
le 7 Avr 2022
You specifically ask for the boundaries for 'holes', so the boundaries you get back include the boundaries for holes.
Your black and white image, top, is after area openning, and you are not doing any hole-filling after that area open.
Your top right and bottom right blobs both have essentially pinholes. Those pinholes account for two of the three extra boundaries.
Your bottom right blob has the larger quadralateral hole; that provides the 13th boundary.
0 commentaires
Image Analyst
le 7 Avr 2022
Try filling holes
obstacles = imfill(~obstacles, 'holes');
[currPoly, L]=bwboundaries(obstacles);
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!