Area Threshold and CorrectIllumination problems

I am trying to create a pipeline that measures the area fraction of tissue stained for DARPP32 protein located in neuron cell bodies. I am working with brightfield images, so I convert to grayscale (split to RGB), invert each “channel” then attempt to correct the illumination before recombining into one image that I eventually threshold.
My main problem is the correctilluminationcalculate function doesn’t seem to improve my image and I wonder if it’s necessary. I need to subtract out the background, but after inverting and correcting illumination, the stained cells become less obvious, so is there a way to increase the contrast of the image, emphasizing the staining in an unbiased way?
I wonder if I even need to invert these images since I can threshold both above and below a specific intensity, meaning that the area measured could be the brightest or the darkest.

I have attached what pipeline I’m working with.

Threshold_invert.cpproj (405.7 KB)

Hi, can you please provide your image so we can have a look how the correct illumination affects it?


I’m uploading the raw image I’m working with as well as the same image processed with imageJ software (turn to b&w, subtract background, adjust window/level, threshold).

I think you might be able to bypass a lot of these issues if rather than splitting and operating on the individual channels you used UnmixColors (maybe with the DAB stain?) to try to pull out what you care about, which I assume is the difference between the dark brown vs the tan vs the white areas of the image.

I also echo what Beth said there, can you point to us which “shade of brown” you want to quantify? I.e. is it the little brow spot or the bigger white object?
And as Beth mentioned, with chromatic stain like this, you better use UnmixColors instead of ColorToGray
Note that you may have to add more than 1 layer to be unmixed to extract the desired channel.


I’m trying to quantify the area of the dark brown spots, excluding any light brown and white. There is variability across the images of my analysis due to taking pictures on different days, and I just want to make sure I reduce illumination background, because when I ApplyThreshold to all of my images equally, some brighter pictures include more background (the light brown) in the area measurement. The UnmixColors is very helpful, thank you Beth. Minh, was the image you produced called “Brown_spot” produced with UnmixColors DAB filter? I think that example is the most helpful for my analysis.


The UnmixColors settings I used was:

At the 2nd box, “Fast_red” can also be DAB.

“Interestingly”, if you then use EnhanceOrSuppressFeature with Enhance >> Dark holes >>> range 10-15, you’ll get this image, maybe useful for you too?

Good luck.