13
$\begingroup$

I am looking for an easy method to count individual particles in a microscopic image. It is quite difficult for Mathematica to detect them, because they are touching each other. I am quite a beginner in Mathematica and can't figure out how I can remove the white centers of the particles. I know there are some similar questions around, but non where the particles have bright centers AND are touching each other.

This is the image:

enter image description here

Thanks a lot in advance.

$\endgroup$
  • 3
    $\begingroup$ Try this blog post: blog.wolfram.com/2012/01/04/… $\endgroup$ – dr.blochwave Apr 29 '15 at 16:19
  • $\begingroup$ That is what I did first. But my image is too crowded with particles. Too many background spaces are clustered together and I just get a very big particle. $\endgroup$ – user28123 Apr 29 '15 at 16:34
19
$\begingroup$

The simplest thing that can work is to search white blobs instead of black blobs, and ignore the ones that have low circularity (calculated from the area/perimeter^2 ratio):

img = Import["http://i.stack.imgur.com/LaMAg.jpg"]
img = ColorConvert[img, "Grayscale"];
components = 
  ComponentMeasurements[
   MorphologicalBinarize[Closing[img, DiskMatrix[5]]], {"Centroid", 
    "Circularity", "EquivalentDiskRadius"}, #2 > 0.75 &];

Show[img, 
 Graphics[{Red, Thick, Circle @@@ components[[All, 2, {1, 3}]]}]]

enter image description here

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ At first glance I thought you were the original poster. Odd coincidence of monikers there. (And a nice answer to a nice question, both of which get votes from me.) $\endgroup$ – Daniel Lichtblau Apr 30 '15 at 14:05
2
$\begingroup$

Preprocess like this:

ClusteringComponents[
  Erosion[Binarize[mySpheres, {.5, .98}], DiskMatrix[1]]] // Colorize

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ This doesn't help in my case. Maybe my question was unclear. I would like to get a binarizes image where the particles are black (also the centers) and the background is white. From there, I think I know what to do, but I just can't get the particles to be all filled black. $\endgroup$ – Niki Apr 30 '15 at 9:25
  • $\begingroup$ Oh.... then just use ColorNegate[]. $\endgroup$ – David G. Stork Apr 30 '15 at 10:20
  • $\begingroup$ But then my particles are not their original size, but smaller!? $\endgroup$ – Niki Apr 30 '15 at 10:47
  • $\begingroup$ So what? You're counting them. $\endgroup$ – David G. Stork Apr 30 '15 at 10:48
  • $\begingroup$ Yes, but I want to determine the equivalent sphere diameter in the end and sphericity and so on ... of the original particle size $\endgroup$ – Niki Apr 30 '15 at 11:06

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.