Extract cells from a microscope image without the lasso selection tool ?

img=

Using the lasso selection tool

one can obtain this:

Thank you so much.
Amin.

Hi Amin,

Looking at how you used lasso to segment the image into different parts, you may be able to automate the process using a program performing segmentation into components followed by component selection.

b = Binarize@img;
c = Closing[b, DiskMatrix[3]];
f = FillingTransform[c]; (* optional *)
comp = MorphologicalComponents[f];
parts = ComponentMeasurements[{comp, img}, "Image", #Count > 1000 &]

You may have to adjust the processing of your image to fine-tune your results. With the current set of parameter values, the approach in this post does not yield as perfect results as your lasso.

Hi,

I had tried something a bit different, with one annoying parameter, but it gives ok-ish results, too. The main idea is very similar but it does not use Closing or FilingTransform, but Blur.

mask = MorphologicalComponents[Binarize[Blur[DeleteSmallComponents[MorphologicalComponents[Binarize[img, 0.05099], 
             Method -> "Convex"], 60] // Colorize, 20]]];
cells = ComponentMeasurements[{mask, img}, "Image", #Count > 2000 &]

Cheers,

Marco

Waw, You guys are amazing and so creative! Thank you so much!

Hi all,

I do see that the problem is already solved. My remark is that a different approach for separating the cells could be in using WatershedComponents. If someone finds this useful, then credits have to go to @Shadi Ashnai, because this method is in perfect analogy to her great post recently . The Code:

ClearAll["Global`*"]
img0 =(* <cell image> *);
img1 = ColorToneMapping@ColorConvert[img0, "Grayscale"];
blur = ImageAdjust@Blur[img1, 30];
marker = Binarize[blur, .5];
ws = WatershedComponents[ColorNegate@blur, marker, Method -> "Basins"];
ImageAdd[Colorize[ws], img1]

which gives:

and finally:

masksNumbers = Union@Flatten[ws];
masks = Function[{n}, Map[If[# == n, 1, 0] &, ws, {2}]] /@ masksNumbers;
imgsParts = ImageCrop /@ (ImageMultiply[img1, Image[#]] & /@ masks)

results in:

Regard – Henrik

@Henrik Schachner.Thank you so much. It really feels great to see how the Wolfram community works!