How to get cell boundaries in the image?
img = Import["https://i.stack.imgur.com/YsIVf.png"];
img2 = Pruning @ Thinning @ Closing[#, 10]& @ DeleteSmallComponents[#, 25000]& @
LocalAdaptiveBinarize[#, 50]& @ GaussianFilter[#, 10]& @ img
HighlightImage[img, img2]
I have somewhat mixed corey's and nikie's approach (check their posts) to arrive at a somewhat reasonable segmentation. Kudos to them.
img2 = ImageAdjust@RidgeFilter[img, 5] // GaussianFilter[#, 8] & //
LocalAdaptiveBinarize[#, 50] & //
DeleteSmallComponents[#, 25000] & // Closing[#, 10] & //
Thinning // Pruning;
HighlightImage[img, img2]
Your image contains thin, line-like structures, so a RidgeFilter
seems like a good idea:
img = Import["https://i.stack.imgur.com/YsIVf.png"]
ridges = ImageAdjust[RidgeFilter[img, 5]]
Die ridges have large brightness variance, but MorphologicalBinarize
works well enough:
bin = MorphologicalBinarize[ridges, {.1, .5}]
To segment the individual cells, I need markers for each cell center. The maxima of a distance transform usually give good markers:
dist = DistanceTransform[ColorNegate@bin];
maxMarkers = MaxDetect[dist, 2];
HighlightImage[bin, maxMarkers]
Now I can use those markers as starting points for a watershed segmentation:
watersheds = WatershedComponents[ridges, maxMarkers];
Colorize[watersheds]
These are segmentation borders highlighted in the original image:
HighlightImage[img, ColorNegate[Binarize[Image[watersheds]]]]