Counting black and white pixels

I am new to image J. I am wanting to count the number of white pixels in a black and white image and the number of black pixels. Any idea what plug in i need for this and/ or how to do it?

I know I can use the pixel inspection tool, but this allows me to only look at 36 pixels at a time and relies on me not making an error. Is there an automated way to do it?
This is the image:

(I downloaded the color counter plugin however this requires RGB values to count and I only want to count B & W)

Many thanks,

Dear @LilyD,

first check if your images are binary images according to the ImageJ definition (8-bit, only 0 and 255 pixel values). If not, you can use the Image > Process > Make Binary command. Once that is done, you can go to Analyze > Set Measurements and enable the Limit to threshold option (also check that the Area box is checked while you are at it).

If you select your image again and do Analyze > Measure, the area column will contain only the number of white pixels since you have enabled the Limit to threshold option (only white pixels are taken into account for a measurement, i.e. from the complete image in your case). You can invert the image (Edit > Invert) and repeat the measurement to get the number of black pixels (that are white after inversion and are thus counted by the measurement).



There are several ways to do this easily with a binary or a greyscale image.

One easy way would be to create a histogram


The press the List action to get the different counts of the histogram as a list.


thank you stefan but how can we do this using the histogram?

Try something like this:

getHistogram(values, counts, 2);


Best regards,

Dear all,
I have a series of images that I need to count number of pixels that have gray level larger than 220.
I tried using the code that stelfrich give, but it asks for exact gray level not larger than specific number.
Is there a way that I do not count all images one by one?
I am not familiar with imagej coding but it should be a code to give us the area of the pixels greater than threshold in all images, in a column…
I appreciate if any one can help me on this.