How can Matlab tell the difference between edges with enclosed boundaries or not?

3 vues (au cours des 30 derniers jours)
asdf
asdf le 6 Mar 2019
Modifié(e) : asdf le 7 Mar 2019
I have the following image
If I use `bwboundaries` on the first object (the white blob), I would expect the boundary to traverse the outer part of that first white object
If I use `bwboundaries` on the second object (the horizontal white line), the boundary is just a horizontal line.
I was hoping there was a way that `bwboundaries` or some other method can somehow classify these 2 objects differently. That is, it could say the first object's boundary starts and ends at the same point, while for the second object, it starts at the left end and ends at the right end
However, if I look closely at how `bwboundaries` traverses these objects, I notice that for the first object, it traverses it once for 360 degrees. But for the second object, it actually starts at the left image border, goes to the right image border, AND THEN BACK towards the left image border.
How can I fix this problem for `bwboundaries` for the 2nd object AND correctly classify these as different objects (the 1st one's boundary should start and end at same point, the 2nd one's boundary SHOULD start and end at DIFFERENT points)?

Réponses (1)

KSSV
KSSV le 6 Mar 2019
For the first object, you may try to arrange the points of boundaries in an order i.e clock wise or anti clock wise. You can do that using this: https://in.mathworks.com/matlabcentral/answers/400247-how-to-plot-closed-polygon-from-set-of-random-points-with-edges-not-intersecting
For the second object, you may try to fit a straight line and get what you want. Read about polyfit.
  1 commentaire
asdf
asdf le 6 Mar 2019
And I want to use bwboundaries because boundaries of all objects in all the images I'm dealing with. The image I posted is just an example of the objects I'm dealing with
I was hoping there was a way Matlab could decide on its own that the traversing the edge for the 2nd object should not begin and end at the same point, so I prefer not using polyfit.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Feature Detection and Extraction dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by