# Segment highly packed nuclei with dotted high intensity signal inside each object

I collected high magnification images on cell nuclei and I need to segment them (red circle in the image). The edges of the nuclei are visible but inside each nuclear object there are bright spots of positive signal (Not an imaging artefact, if I will retake the images it will be the same).

I tested different way to segment the image (using python scripts based on scikit-image, scipy.ndimage and opencv): - Threshold->morphology (close/opening)-> watershed (after gaussian filtering or median filtering to try to remove the dots) - Graph-cuts (Al-Kofahi algorithm implemented in the Farsight package: https://github.com/gbkedar/farsight)

All the methods lead to oversegmentation because of the internal bright spots.

To solve that I thought was a good idea to isolate the dots with a laplacian of gaussian and used the opencv function cv.inpaint to fill the dots with the intensity of the surrounded pixel values. The result was not good either.

The questions are: - Do you think that the best strategy is to isolate the bright dots and then try to replace them with the surrounding signal? - Any strategy that will lead to a better result?

Any help will be greatly appreciated

I wouldn't bother with correct bright pixel segmentation. I think such a strategy would add complexity and another stage in the algorithm which might add errors at the eventual product.

I would use some form of scaling function for the pixel value so that the bright pixels would blend-in better while maintaining contrast in the darker pixels. One such function could be the log function:

im = log(double(im));

Another one might be the square root. You might even get away with using a max value for the image , e.g.

thr = 150; im(im> thr) = thr;

or a combination of both, for instance a capped transform function thr = 100; tform_im = img.^0.5; tform_im_scaled = tform_im - min(tform_im(img>thr)) + thr; img(img>thr) = tform_im_scaled(img>thr);

Either way good luck!

• Do you think that the best strategy is to isolate the bright dots and then try to replace them with the surrounding signal?

If you are trying to diminish the effect of the bright spots on the segmentation algorithm's output then you can try a simple gaussian low pass filter or a median filter.

The output of the Gaussian low pass will effectively "blend" the bright spots with their background (due to the averaging). The controlling parameter of the filter is the width of the gaussian (or its "standard deviation"). A key observation in choosing this technique is that the size of the spots is much smaller than the size of the nuclei. That is, the biggest nucleus is 7-9 pixels in diameter when the delineated nuclei are at least 20 pixels wide. Therefore, the bright spots occupy higher spatial frequencies and the low pass filter will reduce their contrast. You can try two gaussians at 5 and 9 px widths and see the result on the high resolution images.

The bad news are that the boundaries of the nuclei will get blured as well. A boundary is a relatively sharp transition of grey values and it occupies high frequencies too, therefore any lowpass filtering will blur it too. This will have an effect on detecting the shape and actual size of the nuclei. But if you all you are interested in is counting nuclei, then you can just get the centroids of the segmented areas.

The alternative is the median, which substitutes the values at a given pixel with the median of the $m \times n$ pixels surrounding it. You can set $m=n=5$ or $m=n=8$ and see the output. The median will also distort the detected contour and this time unpredictably.

The next step to consider is selective application of these filters over $m \times n$ patches depending on a threshold of their variance. That might give you a bit more control over the smoothing action because the material inside the nucleus has different "texture" (i.e. variance) than the material outside of the nucleus.

Hope this helps.