img=enter image description here

Using the lasso selection tool

one can obtain this: enter image description here

How one can code this to process a large number of images? and is it possible to get the different parts of the images in a squared format like a regular image ? Many Thanks.

Please find answer to this question here:http://community.wolfram.com/groups/-/m/t/958338

  • $\begingroup$ I assume you want to separate the individual cells (are they cells?). One of the keywords is "image segmentation" and you will need to use functions from here: reference.wolfram.com/language/guide/SegmentationAnalysis.html Doing this sort of things automatically and reliably is usually not at all easy and takes a fair amount of trial and error with multiple methods. You would also need a set of several images of the kind you want to segment, to make sure that the method works on most of them. This is just a starting point and I don't have an answer for you. $\endgroup$
    – Szabolcs
    Nov 7 '16 at 13:49
  • $\begingroup$ @Szabolcs. You are completely right. I get it. But really all I wanted to find out here is wether I can litterally cut the image programmatically in the same way you woud cut with a scissor ;). Thank you though for your consideration. $\endgroup$ Nov 7 '16 at 14:22
  • $\begingroup$ @Szabolcs. Sorry I missed your question. These guys are organelles inside the cells stained with a fluorescent dye but yes, your guess is correct, each one of them is inside one cell which we don't see with fluorescence microscopy unless they are stained or tagged with some kind of fluorescence. $\endgroup$ Nov 7 '16 at 19:40
  • $\begingroup$ Again, please add links between questions cross-posted on MSE and Wolfram Community. $\endgroup$ Nov 8 '16 at 17:08

Here is quaky way.

img = Import["https://i.stack.imgur.com/rpeI0.png"];
img1 = DeleteSmallComponents[img // ImageAdjust // Binarize, 5];
img2 = Colorize[ImageForestingComponents[img1] - 1]

Now the patches are distinguished, you can pick them individually by choosing the proper color.

cols = DominantColors[img2, 10]
(*cols[[1]] is background - black*)
ColorReplace[img2, {cols[[2]] -> White, _ -> Black}];
b = DeleteSmallComponents@FillingTransform@%
img3 = SetAlphaChannel[img, b]  

enter image description here

  • $\begingroup$ @Sumit.Thank you so much. the second part of the code yielded error message. Is that because img3 was run as an input before it was defined ( a typo) ? Do you mean this:cols = DominantColors[img2, 10] (cols[[1]] is background - black) ColorReplace[img2, {cols[[2]] -> White, _ -> Black}]; b = DeleteSmallComponents@FillingTransform@% img3 = SetAlphaChannel[img, b] $\endgroup$ Nov 7 '16 at 14:52
  • $\begingroup$ Sorry @PureFunction. You are right. It is img2. I did some trial and error and finally forget to correct the variable :/ $\endgroup$
    – Sumit
    Nov 7 '16 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.