views:

43

answers:

4

Hi,

I want to change the colour of a product in an image. for example http://www.momgoesgreen.com/wp-content//ikea-blue-bags.jpg. I want to change the colour of the product to anything i like for example to black, red or brown using python . Please give a sample code

Thanks

+1  A: 

PIL (Python Imaging Library) may have some hue management stuff.

Marcelo Cantos
A: 

This is non-trivial. In your demo, you have a white background but most often, you will have to cut out the product. Also, color changes with the angle of the surface in respect to the light source and the observer. Unless you have the 3D data, you can't really simulate the correct effect.

To understand this better, download GIMP and try to manipulate the colors in there. It should give you an idea what computers can do today.

Aaron Digulla
A: 

1) This is, as you've been already told, non-trivial. I shouldn't expect anyone providing you with a sample code here, at least not with useful sample code -- although there might be some heroic efforts, you never know.

2) As just one reason one this is non-trivial, consider this: you may reasonably want to change the bag color to red, but you'll probably want the letters on the handles to remain the exact same shade of yellow (IKEA's corporate Pantone 109). Maybe even the handles should remain blue, if they are Pantone 293 -- the second IKEA's corporate color?

3) Having said that, what you can try is convert the image into HSV or Lab or some other such space, select the appropriate colors in the HS or ab plane and shift this region into where you want it to be. Another (even more challenging) approach will be to select the object by what's called "magic wand tool" in Photoshop, and then applying color changes to your selection. In both cases you'll have to pay careful attention to the slightly bluish pixels around the edge of the bag.

AVB
A: 

Your best bet is to fireup photoshop and create alternate images for your site. Cut the bit you want to change out, edit it using one of the colour manipulation tools (not tooo difficult) then paste it back over the original.

SLC