# Is there a way to characterize a winding object in an image?

I have produced this image by applying a Gaussian image substraction, Binarize, Colornegate, and MorphologicalComponents to the original image:

As you can see by the different colors, the colored parts are mostly separate, and consist of a fairly thin but very winding pieces (if you could take one and lay it out to be straight, it would have a fairly high aspect ratio). I'm interested in finding a way to characterize the "thinness" of the pieces that make up the image, so that I could make a histogram of it.

Obviously the width I'm talking about changes along the length of each of those pieces, so I would be fine with some sort of average.

I'm kind of looking for something similar to the Convex Hull properties of ComponentMeasurements, like the Width property, but that does the border that surrounds the whole object, and also includes some space outside of the piece, if they're shaped like mine (if I'm understanding the concept correctly).

I can think of a few ways, but they'd pretty bad. One would be to chop up this picture into an ensemble of smaller ones, where the different pieces in each one would be more elliptical, and then use the properties of the best fit ellipse of ComponentMeasurements[].

Another way I can think of is to adjust my Binarize threshold so that more of the pieces become separate, and then use the ellipse properties again, and then I guess do an adjustment to see how much material was lost in doing that, and compensate for it, if that makes any sense. However, it's also pretty messy and inaccurate.

Another way maybe: replace each piece with a series of connected circles, similar to in the following picture, then just use the radii of the circles. However, it's a little past my abilities, so I don't know if it's possible:

edit: I've tried the last method and got it to work, kind of:

(I zoomed in on part of my original image because the circles were making it unclear at the original magnification.) It works pretty well: the circles, for the most part, cover most of a given piece, and not too much outside the piece.

I would still love to hear any better methods. This one has some possible flaws, like extraneous circles being added and throwing off the numbers.

Does anyone know of a better way to do this?

Thanks!

• To characterize the "thinness of the pieces that make up the image" how about the ratio of the perimeter to the area of each piece. These can be extracted directly using ComponentMeasurements. – bill s Aug 4 '15 at 19:41

You could use the mean distance from the boundary, which for a long thin object is about 1/4th of its width.

image = Import["http://i.stack.imgur.com/2G491.png"];
m = MorphologicalComponents[image];
d = DistanceTransform[image];
widths = ComponentMeasurements[{m, d}, "Mean"]
(* {1 -> 2.40336, 2 -> 5.08581, 3 -> 2.7668, ... } *)


Here are the original components coloured by "width":

Image[Raster[Replace[m, widths, 2], ColorFunction -> "SunsetColors"]]


Using "Max" instead of "Mean" gives slightly different results:

The choice is whether you want to consider a long thin piece with one thick bulb attached to count as thin or thick.

• +1. If you only want the local maxima of the distance transform, you can use SkeletonTransform. If Mean/Max are not enough, you can use ComponentMeasurements[... "Data" to get the pixel values in the distance transform/skeleton image. – Niki Estner Jan 9 '15 at 8:53