3
$\begingroup$

It's actually the same question as here: Identify circles in Image and make list of all diameters

...but I cannot get it to work properly for this specific case, so I would be pleased for some help. I don't see where the error is.

enter image description here

What you see is photoresist pillars on a glass substrate. What I would like to do, is to get the mean diameter in x and y-direction as well as the mean period in x- and y-direction.

Now, instead of doing all the measurement manually, I was wondering, if maybe there is a way to automate it using mathematica ?

So, I wrote this code:

img = Import["image_01.jpg"];
binarized = MorphologicalBinarize[img, {0.3, 0.7}];
cutImage = ImageTake[binarized, {10, 680}, {0, 850}]

enter image description here

components = MorphologicalComponents[cutImage] //Colorize

enter image description here

As you can see thanks to the //Colorize, MorphologicalComponents sees the substrate as a component, but I would like to have the ellipses as components to measure them. How can I do that?

$\endgroup$

1 Answer 1

4
$\begingroup$
components = MorphologicalComponents[cutImage];
params = ComponentMeasurements[Image[1 - components], 
   {"Centroid", "SemiAxes", "Orientation"}] // Values;
HighlightImage[cutImage, 
 Graphics[{Red, {Point[#[[1]]], Rotate[Circle[#[[1]], #[[2]]], #[[3]]]} & /@ params}]]

enter image description here

params2 = ComponentMeasurements[DeleteSmallComponents@Image[1 - components], 
   {"Centroid", "SemiAxes", "Orientation"}] // Values;
HighlightImage[cutImage, 
 Graphics[{Red, {Point[#[[1]]], Rotate[Circle[#[[1]], #[[2]]], #[[3]]]} & /@ params2}]]

enter image description here

$\endgroup$
5
  • $\begingroup$ Thanks a lot. I didn't know that you could do [1 - components] since 1 is an integer and components a matrix. But it seems to be working fine ! Thanks a lot ! $\endgroup$
    – james
    Feb 12, 2019 at 13:31
  • $\begingroup$ @james, you are most welcome. $\endgroup$
    – kglr
    Feb 12, 2019 at 13:32
  • 1
    $\begingroup$ Mathamtica is so streight-forward. Hmm, how am I going to delete all the small components in my image ? Ah, yes, 'DeleteSmallComponents' will do the trick. Nice! $\endgroup$
    – james
    Feb 12, 2019 at 13:34
  • 2
    $\begingroup$ You don't need MorphologicalComponents here, ComponentMeasurements[1 - cutImage will do the same thing $\endgroup$ Feb 12, 2019 at 13:56
  • $\begingroup$ Thank you, @NikiEstner. Great point. $\endgroup$
    – kglr
    Feb 12, 2019 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.