MATLAB: How to calculate the curvature of a boundaries in binary images

color code of the curvatureCurve Fitting ToolboxImage Processing Toolbox

Dear all,
I have a binary image that contains one shape as I show below:
I want to represent the curvature using color coding of the boundariessimilar to image I got from the video in this link http://en.wikipedia.org/wiki/Curvature
Does anyone knows how to do that?
Any help or suggestion will be appreciated.
Meshoo

Best Answer

Use bwboundaries to get a list of the (x,y) boundary coordinates. Run around that border taking a section of the curve, say 9 elements, and fit a polynomial to it. Knowing the derivative of the curve model you used, and the coefficients polyfit() gave you, you can get the curvature at each point. Then run around the list of (x,y) edge coordinates using a marker color that corresponds to the curvature. Try to program that up. If you can't do it all , then post what you have and I'll try to help with the rest.