Thresholding using intensity histogram

intensity
imagemath
displayhistogram

#1

Hi all

I am new to grad school and cell profiler and my first task with the great software is a challenging one! I have a larger cell tracking issue but I first want to nail down my background segmentation. I wanted to know if it was possible to have a pipeline calculate an image intensity histogram and use that information in the pipeline. So if I wanted to classify the bottom port 3% of values as background. If I had that adjusting based on each images histogram that would be preferable.

Any help is much appreicated


#2

Hi,

All the thresholding methods essentially calculate an image intensity histogram; I’d read the help of the ApplyThreshold/Threshold (2.2 vs 3.0 nomenclature) module for more information.

Unfortunately there’s no straightforward way* to get CP to just return you the pixel intensity at ___% (except the top, bottom, and the 25%/50%/75% quartiles) and set that as a threshold. The RobustBackground Thresholding method does allow you to specifically include or exclude certain percentiles of the histogram though when making your threshold choice, so that may be a way for you to exert some of the control over the histogram you’re looking for.

Good luck!


(*= There’s a super not-straightforward way to get the 3.125 percentile value of the original image. I do not recommend you actually do this for your thresholding to make objects, as I think most simple strategies would work better, but if you really, really needed something around that 3% value:
1)Do MeasureImageIntensity on the original image
2)Do (Apply)Threshold on the original image with the Global->Measurement option using the LowerQuartile measurement. You now have a mask of the lowest 25% (in black) and higher (in white).
3)Do MaskImage on the original image with the mask you just made with “Invert the mask?” set to “Yes”; you now have an image containing only the 25% dimmest pixels (and everything else set to 0)
4-6)Repeat steps 1-3 on the masked image you ended up with at the end of step 3; this will get you an image with the bottom (25%)^2, or the bottom 6.25% of pixels with everything else set to 0.
7)Do MeasureImageIntensity on the image from step 6- the MedianIntensity reported here represent the 3.125 percentile.


#3

Thanks for the prompt reply. I am trying to keep as much as my image as possible and would prefer to threshold manually. I was thinking of dropping the bottom 1-3% would be a decent start. I know I need to knock off the lowest bin. I sort of have a hard dataset to work with since my signal is weak and I need to segment into low and high expression buckets on intensity. I wanna put a large gain on the images to make differences more stark but I would like to have a clean background by flattening any intensity below my background threshold.