Help with counting pixels in image imagej

Hello,

I was wondering if anyone could help me with a problem I am having on ImageJ. We need to analyze the pixels in a specific area of our images. However, I have tried using the color threshold and the binary (grey scale) and the threshold with that and analyzing the pixels by going to analyze particles. However, this come out as just a count of one or two for an 2 X 2 micron square box. I do not know what else to try to count the individual pixels in this specific area. Thank you for the help!

Could you provide us with example images? So we can test different approaches :slight_smile:


Hope these help! I appreciate the help.

So as far as I understood: You want to measure the area of a specific signal in your images. You can do that by intensity thresholding. Just make sure the result is specific to your objects of interest.

The images you provided are .jpgs! They are not suitable for quantitative image analysis due to compression: https://imagej.net/Principles#Why_.28lossy.29_JPEGs_should_not_be_used_in_imaging

If you have a suitable file which in your case is most probably orignally a greyscale. I would apply a filter first, to get a better segmentation result. The median filter preserves the edges: Process > Filters > Median…
Use a filter size that is in the range of your object size.

Then apply an global intensity based threshold: Image Adjust > Threshold…
https://imagej.net/docs/guide/146-28.html#sub:Threshold...[T]

Pressing apply generates a binary image (black and white, value 0 or 255).
To measure the pixels in the binary mask go to Analyze > Set Measurements… and select area and area fraction. This will give you the area of the entire image and the percent of pixels that where above threshold. From this you can compute the number of pixels that were above the threshold.

You could also set area alone and Limit to threshold. This will give you a pixel count of the pixel above threshold directly.

1 Like

Hello,

Thanks for the help! I did that and it worked. But, is there anyway to measure the number of pixels in a specific region. Like a 2x2 micron box?

Thank you

You can use a rectangle selection. The measurement should then be restricted to this selection.
Create a rectangle of a specific dimension and add that to the ROI manager t or Analyze > Tools > ROI Manager… and then Add [t]. The ROI Manager allows you to reuse the selection.

Macro for rectangle, with origin x,y and dimensions x,y
makeRectangle(0, 0, 100, 100);