Cell counting in ImageJ

Hi all,

I am new to ImageJ and currently I want to automatically count cell. My picture looks like this: Screenshot 2021-02-19 at 17.25.18

I found online several methods to count cells automatically in ImageJ. In their pictures, particles have color black and background has color white. However, in my case we only have black contours around cells and I could not simply use fill-holes to get the cell masks. Therefore their methods can not be used in my case.

How can I deal with my picture? Thanks in advance!

Hi @rlsssss
fill the background area with the background color.

Here is a short macro:

// Set Drawing color to White
setColor(0, 0, 0);

// Find a background pixel position .. here pixel at x=0, y=0
// .. and fill the background by FloodFill operation
floodFill(0, 0);

// Binary images in ImageJ are 0|255 (not 0|1)
run("Multiply...", "value=255");

// Prepare the image for ParticleAnalysis by making it Binary
// (Menu command: Process>Binary>Make Binary
setOption("BlackBackground", true);
run("Convert to Mask");

// Run ParticleAnalyzer
run("Analyze Particles...", "exclude include add");

The result is this:

Maybe this will help you to start … :slightly_smiling_face:

1 Like

Thanks a lot!!! It works! :clap:

For the sake of completeness …

Your original image has a very specific LUT which can make the handling a bit tricky.
To overcome this you can apply the gray LUT.
And you can use an alternative way to change the pixel intensity.

Here is a macro version II (the result of this macro is identical to the above):


setColor(0, 0, 0);
floodFill(0, 0);

run("Analyze Particles...", "exclude include add");

Thanks @Wayne for the guidance. :wink: