Problem identifying nuclei with IdentifyPrimAuto



Hi, I wish one of you more experienced users can help me with this. I have been trying to use IdentifyPrimAutomatic module to find nuclei of parakeratotic corneocytes stained with H & E. Since these nuclei often undergo degeneration, they tend to have variable intensity (darkness), while the background can also vary from red to light pink depending on the nature of keratin. I guess that is causing problems with different thresholding methods. I’ve tried different algorithms and am currently using MoG Adaptive, threshold range [0.3, 0.6], fraction 0.02. But it seems many relatively light gray nuclei are not captured, or only partially captured. Could anyone suggest a different algorithm, or maybe different settings that work better? Thanks. Attached are some pictures with identified nuclei outlined.



You might want to give a try at inverting the intensity of the image using the InvertIntensity module to make the light areas dark and vice versa. Since many images in microscopy are light objects on dark background (such as in fluorescence microscopy), oftentimes you’ll have better luck with thresholding an image in which the area represented by light objects is smaller than that represented by the dark background.

Also, after inverting, you can use SmoothOrEnhance with the setting “Enhance bright speckles (tophat filter)” to try to reduce the intensity difference between the tissue and the non-tissue regions, and thereby make the nuclei stand out more. Pick a filter size which is a bit larger than your average nucleus size.

Let us know if this helps,


Yes, it looks like the images have three types of regions: the bright white background (outside the tissue area), the light gray background, and the darker gray nuclei of interest. The algorithms are typically designed to look only for two regions at a time, so the two types of background probably confuse the algorithm a bit. Mark’s suggestion may help in this. You might also try using CorrectIlluminationCalculate - “regular” and “Each” options, with smoothing to try to generate a smoothed image that looks mostly like the light gray background and wherein the darker gray nuclei are smoothed out and not really visible. Once you get the settings to make CorrectIlluminationCalculate produce that sort of image, use CorrectIlluminationApply to divide the original image by the result of CorrectIlluminationCalculate. That might make the darker gray nuclei stand out above both types of background and help to accommodate the fact that from image to image the darkness of the nuclei varies (in essence normalizing the images relative to each other).

Of course, before doing all this, you should indeed InvertIntensity so that the “darker gray” nuclei will actually be the lightest objects in the image, but hopefully you follow the logic anyway.

Please let us know whether you find something that works for you. It’s a challenging image but should be feasible so let us know if you can’t get either of these options to work. Also, we hope to soon have a three-class thresholding algorithm that might be able to more readily identify the two types of background and separate the nuclei from both of them.



Hi jies,

We have recently started experimenting with adaptive spatial regularization (Woolrich and Behrens, IEEE Trans Med Imaging 2006). At the moment, we have a preliminary, partially-working CellProfiler module. Attached is the result for your image (D242-01), without any tuning. To my untrained eye, it looks like an improvement in terms of completely capturing light gray nuclei. Can you please take a look and comment on this?

There is quite a bit of clumping because the preliminary module does not do any of the declumping tricks that IdentifyPrimaryAutomatic does. That can be addressed.

Based on the attached image, do you think there is a basis for a collaboration? If so, please email me ( so we can discuss your project.



Hi, Jies and Vebjorn,

The below nuclear outline module is fabulous! Is it a module in CP available for others to use? Also, does it work only on H&E stained images?

Thank you,



The current, preliminary module is not ready for incorporation into CellProfiler because the code is a little shaky and because we do not yet have a good understanding of what kind of images it works well on. I think applying the method at this point would require a bit of trial and error as well as some additional development in order to address the clumping issue.

If you have images that IdentifyPrimAutomatic cannot handle well and you think the new module may do a better job, I am interesting in collaborating. Please contact me by email (