How to find near circular objects in an image?

how to find holes in objects in matlab image?

  • is it possible to find holes in connected components, i.e in objects in an image. if so, can we also count holes? Like, I have used cc = bwlabel(image); to do connected components labeling. Now, how to find number of holes in each object ?

  • Answer:

    You could use the Euler characteristic. From the Matlab documentation: The bweuler function returns the Euler number for a binary image. The Euler number is a measure of the topology of an image. It is defined as the total number of objects in the image minus the number of holes in those objects. You can use either 4- or 8-connected neighborhoods. But be aware that a single pixel "hole" can change the Euler characteristic. You might want to use some opening/closing to smooth object outlines before using bweuler.

Ayesha Khan at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

A hole is the presence of nothing, so you can just invert the image and then count connected components.

thiton

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.