Counting cytoplasms and nuclei within cytoplasms



Hi all,

Please see the picture below of a slide stained with DAB (brown) and Haematoxylin (purple). I need help counting the purple nuclei vs. the brown cytoplasms. The cytoplasms are mixed together so they are difficult to differentiate. Thank you so much.


Hi Sherry,

Taking a look at your particular image, I think you might have some success if you use ColorTogray to split the image up into it’s red, green and blue components (RBG). Some colors are enhanced in a particular channel and you can use just that channel for identifying the features you are interested in.

For example, the brown DAB seems to be prominent in the blue channel, so you can run IdentifyPrimAutomatic on the blue channel to get the DAB (you should invert it first using InvertIntensity, since IdentifyPrim assumes you are looking for light objects on a dark background).

Similarly, the green channel seems to enhance both the brown and purple nuclei. So you can use InvertIntensity on the green channel (to get the bright objects), then use IdentifyPrimAutomatic on the result to get all the nuclei.

Since you want just the purple ones, you can (a) use MeasureObjectIntensity on the nuclei above using the inverted blue channel as your image, then (b) use FilterByObjectMeasurements using the mean intensity (Intensity category, feature number 2) with an appropriate threshold.

The reason this works is that you are taking advantage of the fact that you have identified all the nuclei but in the inverted blue image, only the brown nuclei are bright. FilterByObjectMeasurements allows you set a threshold of maximum brightness that will exclude the brown nuclei, leaving the purple ones.

Hope this helps,


Hi Mark:

Thank you for your reply. I appreciate your advice. The problem is that I need to count the number of cytoplasms that are stained brown with DAB. Counting the # of purple nuclei is easy but counting the # of cytoplasms is more difficult. Feel free to leave any suggestions.



Hi Sherry,

How I answer your question depends on how you count the cytoplasms. Since you’re more familiar with the biology than I, I would need more information on precisely what and how you’re counting.

So for example, the big brown blob in the middle of the sample picture. How many cytoplasm(s) are represented there, and how can you tell (i.e., what visual cues do you look for)? Once I know that, I can better assess whether CellProfiler is up to the challenge :slight_smile:



Hi Mark,

Sorry for not being clear. To tell you the truth, I am having trouble defining the criteria for the cell’s cytoplasm. These cytoplasms extend outward and do NOT have nicely defined shapes. The picture below is an example of one cytoplasm (stained with DAB brown).

All I can define for sure is that the cytoplasms will be DAB brown and they can overlap and neighbor each other.

Thank you,


Hi Sherry,

This is where things can become complicated. The performance of CellProfiler is only as good as the criteria you provide, so if the researcher can’t tell what feature they’re looking for, it’s unlikely CellProfiler will be able to do so either.

However, the result of trying various approaches using CellProfiler can be informative in refining your intuition; it’s kind of a two-way street in that way.

So, thus far, we can get CellProfiler to extract the brown cytoplasms. If they are non-overlapping, then it’s not too hard. For the picture of one cytoplasm you provided, using IdentifyPrimAuto with the default settings will probably attempt to divide it into multiple objects if you tell it to do so based on intensity. You can adjust the amount of smoothing it does prior to segmentation to prevent this (under “Size of smoothing filter”). Or you can tell it that two peaks in intensity within X pixels of each other are indicative of one object and not two (under “Suppress local maxima”). So a trial and error approach on these settings in IdentifyPrimAuto may be helpful.

Or, if you can get IdentifyPrimAuto to identify the approximate center of the cytoplasm (however you define that to be), you can then use IdentifySecondary to use the central region as a “seed point” to extend and fill in the cell boundaries based on the inverted blue image. That’s helpful if you have two (or more) cytoplasms connected to each other and you don’t necessarily know where one stops and the other starts, but you know where the main part of the bodies are; IdentifySecondary will attempt to produce the dividing lines between cytoplasms.

I hope these pointers are helpful in getting you started!


Thanks Mark. I will give it a try.