countobj - count objects in a binary image
The matrix w represents abinary image. It contains elements from the set {0,1}. This functions counts the objects represented by values "1". The tricky things with objects is always: How do you define an object ? This function takes always the enclosing shape. When you have a small ring inside a large ring, then the inner ring is not counted !
This function is based upon a "line integration" method, not on binary erosion or dilations !. From a binary image we determine the contour lines. Now we take random points from these curves and we check, if they are enclosed by other curves. If not, then the counting result is increased by on, otherwise not.
However, at the end of the function a graph is drawn showing the counting results.
w=bmpread(); // Read Bitmap (8 Bit) wbin=bool2s(w>128); // create binary image [ct,kprest,csdata, centers]=countobj(wbin); // End of Demo
cauchy ,