I have this picture of small particles in a polymer film. I want to count how many particles in the figure, so that I can have a rough estimation of the particle density. But the image quality is poor, I had a hard time to do it.
I have tried several ways to do it, but failed. below is the code. The first method I tried is:
`SetDirectory["C:\\Users\\mayao\\documents"]
image = Import["Picture3.jpg"];
imag2 = Binarize[image, {0.0, 0.8}];
cells = SelectComponents[DeleteBorderComponents[imag2], "Count", -400];
circles = ComponentMeasurements[ImageMultiply[image,cells],"Centroid", "EquivalentDiskRadius"}][[All, 2]]; Show[image, Graphics[{Red, Thick, Circle @@ # & /@ circles}]]
So it does not count all the particle. Plus, it sometimes take several particle as one.
I read another method from a thread here, the code is:
obl[transit_Image] := (SelectComponents[
MorphologicalComponents[
DeleteSmallComponents@
ChanVeseBinarize[#, "TargetColor" -> Black],
Method -> "ConvexHull"], {"Count", "SemiAxes"},
Abs[Times @@ #2 Pi - #1] < #1/100 &]) &@
transit; GraphicsGrid[{#, obl@# // Colorize,
ImageMultiply[#,
Image@Unitize@
obl@#]} & /@ (Import /@ ("C:\\Users\\mayao\\documents\\" <> # \
& /@ {"Picture1.jpg", "Picture2.jpg", "Picture3.jpg",
"Picture1.jpg"}))]
But it does not recognize the single particles:
Is there any other method to do this task? Thanks a lot for any suggestions.