# How to calculate particles sizes for spheric particles with overlapping and superposition? (Example image included)

I'm trying to automatically calculate particles sizes histogram for images like this one:

Common threshold and segmentation doesn't seem to work. What filters and algorithms do you suggest to be used?

Here is what I experimented with:

1. Use ELSD to generate elliptic contours. You could basically use any edge detector, but since in the following stages I will benefit from circle detectors, it is good to already have some geometrical edges. Here is what the output looks like:

2. Collect all circular (also non-circular) edges via collecting the channels into a single image. This can also be done via simple thresholding. Again, the output looks like:

I will denote this image to be $C$.

1. We will now compute the circular hough transform on this image. However, there are many spheres (which appear to be circular) in varying radii. Thus, we select a range $\mathbf{r}=\{9, 12, 15..150\}$ to be the expected radii per hough transform. The pseudocode looks like:

$c_x$ $\leftarrow$ $\emptyset$, $c_y$ $\leftarrow$ $\emptyset$

for all ($r_i \in \mathbf{r}$) $\{$

{x, y} = hough_circles($C$, $r_i$)

$c_x \leftarrow \{c_x \cup x \}$

$c_y \leftarrow \{c_y \cup y \}$

$\}$

Depending on the peaks of the accumulator, Hough might report multiple center locations. A simple clustering might help avoiding this (Just average the close-by centers).

The final image with the resulting centers overlayed (in different colors), looks like:

You could customize the radius to be robust to different circles. Moreover, one can use elliptic Hough transform to have a better coverage of the particles (as some of them are not circular). Finally, the much-occluded large circles can be obtained after masking out the small ones - even with the help of a distance transform. If the false circle hypothesis are desired to be eliminated, you can always reduce the Hough sensitivity. Or you could always render the contours of the circle and compare to the detected edges.

• Thanks for the complete answer, Tolga! The ELSD algorithm really makes a difference here! I just have some more questions about how you arrived at this final image: how did you choose the thresholds when selecting the local maxima from the Circle Hough Transform? I'm trying a lot of different values for relative and absolute thresholds, but I'm getting either very few circles, or a lot of similar detected circles for the same balls. – e.tadeu Apr 18 '16 at 23:36
• One thing I did was to cluster the similar centers together by averaging, so that they don't appear multiple times. This way you'll be less sensitive to the multiple peaks on the Hough transform. – Tolga Birdal Apr 19 '16 at 6:23
• The ELSD link needs user: demo, password: demo – Olli Niemitalo Apr 20 '16 at 13:23
• The ELSD demo link didn't work for me directly (gave python errors) but going to it via ubee.enseeiht.fr/vision/ELSD worked. – TripeHound Jan 2 '18 at 12:23
• Even though it's a couple of years old now, I still can't find any Python implementation of that ELSD method. – Aaron Bramson Jul 24 '18 at 6:36