4
$\begingroup$

I have this file that will always have a white background and I would like to separate the elements into separate files, but I don't know which function to use.

This is the file:

enter image description here

img = Import["https://i.sstatic.net/WydPS.png"]
ColorQuantize[img, 20, Dithering -> False]

I would just like to extract the images as follows:

enter image description here

enter image description here

enter image description here

If this question is very simple or is a duplicate, I would like a guidance

I have Mathematica version 11 available

$\endgroup$
1

1 Answer 1

4
$\begingroup$
Values @ Rest @ ComponentMeasurements[img, "MaskedImage"]

![enter image description here

Values @ ComponentMeasurements[ColorQuantize[RemoveBackground[img], 5, 
     Dithering -> False], "Image"]

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ I tested it with images with a white background, but with shadows in the images and it didn't give the same result. It worked well with colors without a gradient. I imagined something like changing the white background of an alpha channel. $\endgroup$
    – LCarvalho
    Commented Aug 31, 2020 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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