# Determine the feature size in the picture

I was doing some fractal dimension calculation using http://community.wolfram.com/groups/-/m/t/1025046 box counting method and I thought to myself if it would be possible to make a constrain that the boxes (or circles) have to touch at least two edges. that would be a great tool to estimate the size of the features in e.g. fibrous network from SEM images.

https://www.dropbox.com/s/0a3t8w4tv9zu9jb/agarose_analysis.jpg?dl=0

and plotting e.g. there are 40 circles of size 30px, 10 of size 29px etc. any ideas how to implement that?

This is relatively easy using a distance transform:

img = Import["https://i.stack.imgur.com/Juolc.png"]
binary = Binarize[img, .9];
dist = DistanceTransform[ColorNegate[binary]];


Now, dist, contains for each pixel the euclidean distance to the closest white pixel. The points you're looking for are (I think) the local maxima in this image:

maxPos = ComponentMeasurements[MaxDetect[dist], "Centroid"][[All, 2]];


Which yields these circles:

Show[binary, Graphics[{Red, MapThread[Circle, {maxPos, radii}]}]]


Histogram[radii, {1}]

These are the circles that are locally maximal. So they're usually touching 3 or more white points. If you want all circles that touch two white points, you should look at SkeletonTransform.
For example, for a square, the method above wold yield only on circle, at the center of the square. SkeletonTransform would yield all points along the diagonals of the square - as circles centered on the diagonals touch the square in two places.
• @dziakku: Sure, you can get gradients (e.g. rainbow colors) using ColorData and create a legend using BarLegend – Niki Estner Oct 12 '17 at 16:13