# Counts and Sizes of Highly Overlapped/Contacted Particles from Microscopic Image

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).

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!

• look at Circular Hough Transform to find circular objects. – Ali Hashmi Apr 15 '17 at 14:32
• mathematica.stackexchange.com/questions/11725/… – Ali Hashmi Apr 15 '17 at 14:32
• @AliHashmi I don't think that is a related post. :) – yode Apr 19 '17 at 20:01
• This may be helpful. – xslittlegrass Apr 19 '17 at 22:39
• @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 – 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.

hp[img_Image,w_Integer]:=Image[0.5+Subtract@@ImageData/@{img,Blur[img,w]}];
img7= Binarize@Closing[ Threshold[ hp[img,30],0.52],1];


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


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];
Colorize[wa];cells = SelectComponents[wa, "Count",250<#<900&];  measures = ComponentMeasurements[cells,{"Centroid", "EquivalentDiskRadius", "Label"}];
count += Max[ComponentMeasurements[cells, "Count"][[All,1]]];
,{s,segments},{index,1,Last[Length/@segments]}]]


You could also address the different sizes issue with classifiers.

• Well,since nobody post answer,I will give you that 100 rep. :) – 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"];
DistanceTransform[
ColorNegate[

Max[MorphologicalComponents[mask]]

1129