I am trying to do a little image segmentation on some cells taken from microscopy images that have uneven illumination. I am having trouble getting the background of the image cleaned up after applying LocalAdaptiveBinarize so I can end up with closed white foreground cells on a plain black background.
Here is the original image:
Due to the uneven illumination (darker in the upper left part of image and brighter in the lower right) I couldn't find a simple threshold that worked well across the whole image so I tried to use LocalAdaptiveBinarize by doing LocalAdaptiveBinarize[image, 10]. Here is the result:
The cells aren't bad but there are a couple annoying defects I would like to improve: One of the two cells in the middle at the top has a chunk of it missing on its lower edge and the cell beneath it has a hole inside it. I can fill in the hole of the bottom cell by using FillingTransform[localBinImage,1] and get this:
I would be interested if anyone has any suggestions on how to improve the cell at the top with the chunk missing from its lower border.
At any rate, with the exception of the top middle cell the rest of the cells now look close to passable but the background is still a mess from using LocalAdaptiveBinarize. I would like to have a way to clean up the background so I just have the cells by themselves on a plain black background that makes it easy to use MorphologicalComponents or something similar to segment the cells.
Any suggestions on how to clean up this background?
ImageMultiply[#, Binarize@DeleteSmallComponents@Erosion[EntropyFilter[Blur[#, 5], 1], 2]] &@ Import@"http://i.stack.imgur.com/5ni1u.jpg"
$\endgroup$Import["http://i.stack.imgur.com/5ni1u.jpg"] // EdgeDetect // DeleteSmallComponents // FillingTransform
. The cell at the top has an "invisible" left boundary, so it doesn't get filled in. $\endgroup$HighpassFilter
to remove the gradual (low frequency) changes in the background illumination while preserving the high frequency changes in the cells. $\endgroup$