# How to make a list of images out of one image without using the lasso selection tool?

img=

Using the lasso selection tool

one can obtain this:

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.

• 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. – Szabolcs Nov 7 '16 at 13:49
• @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. – Pure Function Nov 7 '16 at 14:22
• @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. – Pure Function Nov 7 '16 at 19:40
• Again, please add links between questions cross-posted on MSE and Wolfram Community. – Daniel Lichtblau 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]


• @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] – Pure Function Nov 7 '16 at 14:52
• Sorry @PureFunction. You are right. It is img2. I did some trial and error and finally forget to correct the variable :/ – Sumit Nov 7 '16 at 14:59