I have an image of concentric circles, I would like to find the radii of the circles (only the innermost few are important).
I've had a go using what I could find in previous posts, but am a bit confused about which method I should be using - if I need MorphologicalComponents, or whether to use SelectComponents "count" or "equivalentradius", or colornegate etc. Sometimes the circles are broken (especially when I binarize), so I need to look for incomplete circles too..
So far I have:
i = Import["http://i.imgur.com/oTTM9MG.jpg"];
b = Binarize[i, {0.3, 1}];
m = MorphologicalComponents[b];
c = SelectComponents[m, {"Count", "Holes"},
1000 < #1 < 20000 && #2 > 0 &] // Colorize
ComponentMeasurements[c, {"Centroid", "EquivalentDiskRadius"}]
or, using :
i = Import["http://i.imgur.com/oTTM9MG.jpg"];
disk = ColorNegate[Binarize[i, {0.3, 1}]];
rings = ComponentMeasurements[
disk, {"Centroid", "EquivalentDiskRadius"},
450 <= #1[[1]] <= 550 && 325 <= #1[[2]] <= 375 &&
10 <= #2 <= 500 &];
Show[{disk,
Graphics[{{Red, Circle[rings[[1, 2]][[1]], rings[[1, 2]][[2]]]}}]}]
Am I making it harder than it is? Could someone bump in the right direction?
both this, How to find circular objects in an image? and this, Finding the centroid of a disk in an image were helpful (but I need to expand it to multiple circles and fit partial circles).
Any help would be appreciated. Thanks!
Answer
What you could do is apply an edge filter and find the threshold which binarizes your image best:
i = Import["http://i.imgur.com/oTTM9MG.jpg"];
edges = LaplacianGaussianFilter[ColorNegate[i], 2];
Manipulate[Binarize[edges, t], {t, 0, .1}]
After that you could select all objects with a certain radius or you throw out all small objects with a specific "Count"
. You have to decide then what you prefer as radius. I thought maybe the "MeanCentroidDistance"
gives a quite stable measure
circles =
SelectComponents[
MorphologicalComponents[LaplacianGaussianFilter[ColorNegate@i, 2], 0.0056`],
"Count", # > 300 &];
Colorize[circles]
ComponentMeasurements[circles, "MeanCentroidDistance"]
(*
{26 -> 271.952, 33 -> 262.778, 129 -> 221.202, 157 -> 209.482,
329 -> 154.293, 398 -> 136.493}
*)
Comments
Post a Comment