You could probably compare the object’s main axes lengths (computing perimeter of an ellipse with that size) with its measured perimeter. Axes lengths measured using Feret diameters, perimeter measured using chain code algorithm. Both methods are explained elsewhere in this blog.

]]>i have some binary images that want to cllasify them base on there shape .if they have circular or elliptical shape they belong to class one,if they be ellipse with dent in their boundary they belong to class one. i dont know how can use this feature. can you help me how can i do this?

Thank your for your helping in advande…

]]>This is an old problem, much code has been written to try to solve it. One thing you could do is take the coordinates of the boundary pixels, in order (as you’d obtain from the chain code), and smooth the two vectors formed by the x-coordinates and the y-coordinates. That is, given 20 pixels along the boundary, you’d have two vectors with 20 values each. You can smooth these by applying a low-pass filter (preferably a Gaussian), and using periodic boundary condition (i.e. assuming `x(end+1)=x(1)`

). From these sequence of points you can compute the second derivative (extra points if you do the smoothing and derivative with the same filter!, see an earlier post on Gaussian filtering). The second derivative will be negative everywhere except at two points, hopefully.

However, it should be much easier to separate your circles using the distance transform + watershed trick. From your binary image, compute the distance transform; this gives the distance to the background for every object pixel. Two circular objects, even when somewhat overlapping each other, will each have a local maximum in their middle. The inverse of this distance transform can be used as input to the watershed, which will create one region for each local minimum (hence using the inverse, so that each object has a local minimum in its middle). The watershed will create a boundary that is exactly like the one you are looking for.

]]>thank you for the many useful tricks that you publish here!

My idea is to use convexity and chaincode to find locally concave and convex parts of my boundary. My objects can look similar to your example boundary. More specifically I want to look at circular-like objects that touch and morph together giving two circles with different degrees of overlap/pinching. I am hoping that I can identify regions where circular parts connect, because this is where the local curvature becomes concave. Then I want to split my object’s boundary into the circular sub-parts composing the individual circle-like parts.

Similar to your chaincode here, my boundaries are not smooth enough/too noisy to look at “diff(cc)” directly (additionally I am not sure how to find the curvature when the direction jumps from 7->0).

Maybe one can identify the concave regions by looking at parts of the boundary that are far away from the boundary of the convex hull? The actual concave part of the boundary can be very short as well, such that a plot of “cc” shows a noisy, monotonously decrasing function, with discontinuities at regions where the boundary goes from one circle to the next circle.

Do you have any comment/idea on how to measure local curvature of a boundary and or how to find discontinuities in the local average curvature?

Many thanks for any advice on this!

]]>