Message Boards Message Boards

GROUPS:

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

Posted 4 years ago
4281 Views
|
5 Replies
|
13 Total Likes
|

img=enter image description here

Using the lasso selection tool enter image description here one can obtain this: enter image description here

Thank you so much. Amin.

POSTED BY: Amin C
Answer
5 Replies

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 &]

enter image description here

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 &]

enter image description here

Cheers,

Marco

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

POSTED BY: Amin C
Answer

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:

enter image description here

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:

enter image description here

Regard -- Henrik

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

POSTED BY: Amin C
Answer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract