1

I wondering what the best way to extract a shape (say some clothes attached) from an image:

enter image description here

i.e. extracting the pink clothes from this image and making the background appear transparent.

My first thoughts were to read this into a numpy array

from matplotlib.image import imread
image_name = "image009.png"
img = imread(image_name)

then compute a histogram on the RGB data to find the most common colour. I can then presume that this most common colour represents the background, white in this example. I can then make the background transparent thus "extracting" the pink clothes.

However, I obviously this approach would fail if the background wasn't the most common colour. Therefore, are there any other solutions or methods people could recommend for achieving this?

Thanks for your help!

ajrlewis
  • 2,968
  • 3
  • 33
  • 67

0 Answers0