Filter löschen
Filter löschen

How to find number of holes in each connected component?

5 Ansichten (letzte 30 Tage)
Ayesha ch
Ayesha ch am 10 Mai 2016
Kommentiert: Image Analyst am 22 Mai 2016
hi i'm new in matlab. I want to find the number of holes in each connected component prior to hole filling. I know the euler number that returns the number of holes in an image as a whole, but i want to find the number of holes in each connected component individually. any help would be appreciated.

Akzeptierte Antwort

Image Analyst
Image Analyst am 10 Mai 2016
No it doesn't do the whole image. It does it on a blob by blob basis. Just check out regionprops(). The Euler number is just like any other blob-specific measurement you can ask it to make.
  2 Kommentare
Ayesha ch
Ayesha ch am 22 Mai 2016
Thankyou so much for the help.I'm using:
n=bwconncomp(S);
h=regionprops(n,'Eulernumber');
Here 'h.EulerNumber' returns 1, -1 and 0 value. I was expecting the actual number of holes, like 10,12 etc. Could you please explain what is meant by 1 and -1? Thankyou.
Image Analyst
Image Analyst am 22 Mai 2016
"Returns a scalar that specifies the number of objects in the region minus the number of holes in those objects."
Normally the number of objects in the region is 1. So a solid object would have an Euler number of 1. An object with 1 hole would have an Euler number of 0. An object with 2 holes would have an Euler number of -1.
I see only one object in your image with more than 1 or 2 holes, are you expecting those numbers for more than one or two blobs?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by