Is there a way to exclude black space in the calculation of mean gray value?

In ImageJ, I set the threshold and then use nucleus counter which selects most of the cells. Then I manually go through and create new ROIs for the cells that nucleus counter missed. Then I measure the average intensity (mean gray value) of all the ROIs.

The problem is that I believe “mean” includes all of the pixels in the ROI, which means it depends on the area selected. So this number will be skewed depending on whether I manually selected the cells (using the elliptical tool, which inevitably includes black space around the cell) or whether nucleus counter selected it (this tool traces around the edges of the particle so that there is no black space in the ROI).

A solution to this would be to somehow have ImageJ calculate the mean excluding all of the pixels that are below a certain value (0). Is there a way to do this?


Hi @cbrusco1

Here is one of the ways it might work. After you add all of your ROIs in the ROI Manager, check “Limit to threshold” option under Analyze > Set Measurements. Go back to your image. Threshold the image with range 1-255 (for an 8-bit image). Important: do not press Apply, leave the Threshold window open.. This will highlight all the non-zero pixels in the entire image in red. Now select your ROIs in the ROI Manager one-by-one and hit Measure.


1 Like

Thank you so much, this works and is my new protocol now.