Classify objects by difference between object brightness and background

Hi, I have 3 channel fluorescent images of cells (ch1 = DAPI, ch2=Marker1 ch3=Marker2) and would like to classify cells according to the intensity of the nuclear marker 1 and 2.
What I do is to detect primary objects in the DAPI channel and then measure the brightness per object in channel 2 und 3.
At the moment, I classify then by absolute intensity thresholds eg.: celltype 1 = intensity > 0.04 in ch2 and intensity < 0.03 in ch3.

What I would like to include now, the consideration of the background. Instead of a hard threshold for the classification, I would like to have something like celltype 1 = intensity object/intensity background > 100.

Is it possible to classify according to results of calculations ?
If so, is it possible to define the background for the measurement of background intensity as all pixels, which are not included in the primary objects?

I would really appreciate any help or ideas on that.

Thanks and best regards



I think the module you mostly need to look at is CalculateMath with the operation set to divide. Here you will make the numerator your nuclear intensity measurement and the denominator the masked image intensity measurement and at the bottom, you can multiply the result by 100 to give you the measruement you want. Just to warn you, the output in test mode gives you some sort of summary number but it does actually calculate per object as you want. When I do similar stuff I quite often use DisplayDataOnImage to view the measurement on each object so I can decide how to filter.

With your second question, to get the non-object image measurement you can use the MaskImage to create an image with your objects masked (invert the mask). Then use MeasureImageIntensity to measure the intensity of that masked image.

Hope that helps a bit, good luck!

1 Like

Hi and thanks for your reply. I was not sure if the masking would set the masked pixel intensity to 0 which then would influence the average background of the picture, or if the masked pixels are just totally spared.

Concerning the classification module. Do you have any idea, if the result, obtained by the CalculateMath module can be used in the classify module in order to automatically classify the cells, according to the calculated value?

Best regards and again thank you for your help!


Well, a good test for your first question is to look at the test mode output for MeasureImageIntensity after measuring the masked and unmasked image. If you do that you should see that the TotalArea measurements are different thus showing that the masked pixels are excluded as you hoped. If for some reason you need extra reassurance you could use the option in the module to measure the area enclosed by your objects. Then you’ll see the area covered by them will be the difference between the two measurements mentioned above and in the masked image the measurements in the area covered by objects will all be 0.

Once you have sorted out the measurement then it should be easy enough to use the ClassifyObjects module as your objects will now have an associated measurement in the category “Math” and then the measurement will be whatever you named it in CalculateMath.

If you are struggling then you can upload your current pipeline, an example image and explain what you need to achieve and I can try and have a look.

P.S. Also just in case you hadn’t noticed it and I don’t know what you do downstream of classifying objects, there’s a module called FilterObjects you could also use which would result in you having filtered objects with above two limits you set on their measurements, in this case, the output of CalculateMath.

1 Like

Hi thank you very much for your helpful answer. I did not find the time to finish my pipelines before, but today I finally found some time to get done with them. First tests look fine and now I am analyzing the first 2000 image sets.
I really appreciate your help!

Best regards


1 Like

Glad to help!

Hope everything continues smoothly :slightly_smiling_face: