Fiji: remove black background from image to calculate mean gray value

Hi there,

I’m new to this forum so many apologies if a similar post has been made and since resolved.

I have a series of images which I’ve cropped so the tiff file assigns a black background that surrounds my images. I want to measure the mean gray value in the tissue but I think imagej recognises the black background as a gray object (measures it as 1 when converted to 8 bit grayscale). As I have a series of images, my plan is write a macro so I can then batch process the images to obtain my measurements. I’ve uploaded my image for reference, which is a section tissue stained with luxol fast blue and cresyl violet. I use colour deconvolution to separate out the stains as I want to quantify the LFB intensity. This automatically converts the image to 8 bit, then I convert to grayscale using lookup tables.

cropped m22 rf lfb.tif (424.7 KB)
gray cropped m22.tif (295.2 KB)

So far, I’ve resorted to using tswayne’s solution by subtracting that 1 pixel from my images as a makeshift solution:

Any further advice would be much appreciated!



Welcome to the forum, @sci_djw!

In your RGB image, the background is indeed (0, 0, 0), so the fact that your grayscale conversion via the colour deconvolution plugin produces an 8-bit grayscale image with all 1s in the background is just a characteristic of that algorithm, I guess.

One thing you could do is to work from your original RGB image, create a selection of only the (0, 0, 0) samples, transfer that selection to the grayscale image, and then set all pixels within the selection to 0. That way, the rest of your data won’t all decrease by 1.

However, I’m not sure how statistically important it is to avoid the 1 subtraction. Already you are going from RGB through the color deconvolution, so “mean gray value” after such operations may not be precisely meaningful. Perhaps others here can comment more confidently on that.