Dear all below is an image from microscope that I have a hard time doing image processing to get the particle counts and the corresponding sizes (the large one is around 1 micron).

enter image description here

The way I did was following the procedures in another post. But it totally failed probably due to the nature of such highly-overlapped particles. Just wondering is there any way to deal with this type of image? Thanks!

  • $\begingroup$ look at Circular Hough Transform to find circular objects. $\endgroup$
    – Ali Hashmi
    Apr 15 '17 at 14:32
  • 1
    $\begingroup$ mathematica.stackexchange.com/questions/11725/… $\endgroup$
    – Ali Hashmi
    Apr 15 '17 at 14:32
  • $\begingroup$ @AliHashmi I don't think that is a related post. :) $\endgroup$
    – yode
    Apr 19 '17 at 20:01
  • $\begingroup$ This may be helpful. $\endgroup$ Apr 19 '17 at 22:39
  • $\begingroup$ @yode i am not suggesting it is similar. what i wanted was to show that there are things that maybe helpful for example Circular Hough Transform, which if implemented in his case, can account for these particles which are essentially circular $\endgroup$
    – Ali Hashmi
    Apr 19 '17 at 22:58

The following snippet will allow you to follow the tutorial that you were initially reading using your image instead. The issue, in this case, is not so much the overlapping elements but to correct the noise from a low-light photo to then binarize the image while preserving contour clarity. Using Manipulate at every step can reduce the false positives dramatically. As you can see the number of false positives increases in certain areas of the photo. To deal with the different sizes you could find an appropriate value for the variables kernel and segmentation_X that correspond to a particular particle size in the Serious and Not-So-Serious Image Processing Applications notebook (or simply the third argument of cells in the snippet). It is a good habit to reuse code when that is permitted but it is also fun to come up with solutions from scratch as well. To get more accurate results you could try to use ImagePartition and compound (including errors) the results from the segments in a Mathematica script as it can process smaller pieces of an image faster without the overhead of a graphical user interface that you can later use to refine your results.

img7= Binarize@Closing[ Threshold[ hp[img,30],0.52],1];
distT =DistanceTransform[img7,Padding->0];
marker = MaxDetect[ImageAdjust[distT],0.02];
w = WatershedComponents[GradientFilter[img7,3],marker,Method->"Rainfall"];Colorize[w]; cells = SelectComponents[w, "Count",500<#<3000&];  measures = ComponentMeasurements[cells,{"Centroid", "EquivalentDiskRadius", "Label"}];Show[img, Graphics[{Orange,Circle@@#&/@(measures[[All,2,1;;2]]), MapThread[Text,{measures[[All,2,3]],measures[[All,2,1]]}]}]]

enter image description here

Max[ComponentMeasurements[cells, "Count"][[All, 1]]]

Here is a slight variation using ImagePartition. The count here was 3,899.

count=0;segments = ImagePartition[img,{250}]; ImageAssemble[ Table[i= Binarize@Closing[ Threshold[ hp[s[[index]],30],0.52],1];
m = MaxDetect[ImageAdjust[d],0.02];
wa = WatershedComponents[GradientFilter[i,1/10^6],m, Method->"Rainfall"];
Colorize[wa];cells = SelectComponents[wa, "Count",250<#<900&];  measures = ComponentMeasurements[cells,{"Centroid", "EquivalentDiskRadius", "Label"}];
count += Max[ComponentMeasurements[cells, "Count"][[All,1]]];
Show[s[[index]], Graphics[{Orange,Circle@@#&/@(measures[[All,2,1;;2]]), MapThread[Text,{measures[[All,2,3]],measures[[All,2,1]]}]}]]

enter image description here

You could also address the different sizes issue with classifiers.

  • 1
    $\begingroup$ Well,since nobody post answer,I will give you that 100 rep. :) $\endgroup$
    – yode
    Apr 25 '17 at 6:45

I have to say this is a challenge tasks in Mathemtica,this answer just a very preliminary start.

img = Import["https://i.stack.imgur.com/QKLHn.jpg"];
mask = MaxDetect[
      Binarize[ImageAdjust[GradientFilter[img, 2]], .3]]]], .05];
HighlightImage[img, mask]

Mathematica graphics

So as my count,the number of particles is



  • $\begingroup$ Thanks @yode how about the particle size (diameter)? Seems like most of the smaller particle can be captured quite well $\endgroup$
    – DavidC
    Apr 14 '17 at 23:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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