Count black objects

I have a problem with the black objects, i can’t count them.

Could you please upload one or two images to clarify better your issue?
thank you
Emanuele Martini

1 Like

Original Tiff file: download

In fact, I have a problem with the reflection of light on black objects and their counting too

the problem of the reflection light produces everytime more or less three white spot on the black objects?
can we identifiy the number of white spot in the black area and then divide them by three to have good estimation of the number of black objects? or would it be to much naive?

There are objects that have 3 points and other 2 points

In a very quick trial using Trainable Weka Segmentation (with the standard settings, and a third class added for the background), I got the following result:

I assume that with some post-processing, it should be fairly easy to filter the objects of interest by size and shape to get a robust count. See also:


You can give me please a link to install Trainable Weka Segmentation ?

I linked it in my post above. Trainable Weka Segmentation comes included with an installation of Fiji:

You can find it using the Command Finder L, or under Plugins > Segmentation > Trainable Weka Segmentation

1 Like

Good day Emna,

would the following be an acceptable count?

It gives 114 recognized black spheres without using a classifier (weka).

Please be aware that a 100% correct number is generally out of reach.




Yes I can count them manually but I would like to have a function that counts the number of pariculates per color

Good day Emna,

was this a reply to my post?

Actually, the posted image shows an automatically gained result, or at least a semi-automatic one. Depending on the image quality you may have to adjust one parameter.

The approach consists of three steps:

  1. color-threshold
  2. correlation with a prototype sphere
  3. analysis of maxima

Apart from my suggestion I wanted to know what precision of the number estimate is required.



1 Like

Dear Herbie,

would you mind explaining step 2 in more detail?

Thank you,

Good day Martin,

well, with correlation I evidently mean the computation of the cross-correlation function.

It’s just the same as e.g. searching all positions of letter “e” in a text page, provided you have one letter “e” of the correct font available as an image.

ImageJ can compute the cross-correlation function of two images (e.g. the text page and the prototype “e”) via complex-valued multiplication in the Fourier-spectral domain. As always, a look at the relevant pages of the manual reveals more details:
(especially: 29.10.7 FD Math… )



1 Like

How about just blurring the shine? This gives me 128. Herbie’s method is probably more robust though.

Gaussian blur 3, Color threshold, find maxima

1 Like

Dear @Emna,

I have just thresholded with the default method of ImageJ the image and set some area constraints to the object to find (i.e. 20-100) with Analyze Particles tool.
Then, supposing that the great majority of the black balls have 3 bright spots I divided the number of ROIs by 3.
I found 373 ROIs /3 = 124 black balls; this number is more or less comparable to the number other has found with other methods.
So now you’ve a lot of methods and approaches to test.

I compared them to a count of them done by hand (points in green on the below image)

by hand (by my hand :wink: ) they are 137.
So it obviously underestimates, but it is not so bad.

As many of us pointed out to you it would be kind by you tell us how much precise you want the estimation of the number of black balls.

But ok, we really don’t know if you are still reading us trying to help you;)

have a nice day,
Emanuele Martini

I do not have an estimate of number but I always try to see is what the count could detect all the particles or not

Excuse me for the delay. Thank you very much for your help emartini and especially for the time you spent. I will try this method because if there is a 10 difference it is not a problem

1 Like

ok @Emna,
nice! :wink:
let me know if it works fine and if you have some “implementation” problems.

have a nice day
Emanuele Martini

Yes, I have a question, how could you detect only the white spots? Because if I put in circularity 20-100 it will detect all the particles