
1 Attachment(s)
Object counting
EDITED:
Hey
I am looking for a quick way to count objects in a binary image (object = 1, background = 0).
I have tried Connected Component Labeling and it works for square shapes but the rounded shapes it has a problems. Could someone have a look at the code and let me know where am wrong.
Attached is what I have done for the connected component labeling.

Are you just just counting bits or do you need to do image analysis of a binary image to find the number of geometric shapes?

It sounds like your just trying to find connected components. Think of it this way:
You have a graph, each cell of your image with a 1 is a node, two nodes are connected if they are adjacent to each other. Now you can just use any old connected component algorithm.
If you are trying to find components based on pixel intensity (ie., not just 0's and 1's) things get a little trickier.

Wouldn't you want to perform some type of Laplace or Sobel edge filter on it first before doing a connected component algo?