change the color of tshirt

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
ratneshsoni
Posts: 38
Joined: 2010-12-14T03:56:10-07:00
Authentication code: 8675308

change the color of tshirt

Post by ratneshsoni »

i send u link in which there is example of changing the color of t-shirt.While changing the color of t-shirt it not remove the wrinkles from t-shirt.
http://www.screencast.com/users/Ratnesh ... 74d16dcd81

it is possible in image magick like that. If not than how it could be possible

User avatar
fmw42
Posts: 25982
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: change the color of tshirt

Post by fmw42 »

see the answers posted at viewtopic.php?f=2&t=17672&p=66829&hilit ... ors#p66829

You will need to trace a mask of the tshirt and then process the whole picture with the following command. Then use the mask to select the background from the original and the colored shirt from the processed image. I have made a quick and dirty mask only. Follow Anthony's suggestions below about anti-aliasing if that is important.


origin

Image


crude mask:
convert shirt.jpg -fuzz 17% -fill none +opaque white shirt_mask17.png


Image


Processing:

convert shirt.jpg \( -clone 0 +level-colors black,lightblue \) shirt_mask17.png \
-compose multiply -composite shirt_lightblue.png

Image
Last edited by fmw42 on 2010-12-21T19:04:31-07:00, edited 1 time in total.

User avatar
anthony
Posts: 8884
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: change the color of tshirt

Post by anthony »

It may be better if the mask have anti-aliased edges to 'feather' the edges a little.

If the original photo was on a darker background the mask may be easier to generate.

However the background of the image is more consistent with its coloring, so it may be posible to generate the T-shirt mask by subtracting the masks for the different parts of the background and skin colors. The edge however may need anti-aliasing.

Basically It would be better to generate the mask ONCE using a interactive image editor such a gimp, or photoshop. Once you have the mask however, automatic color adjustments is easy.

Multiply is one way of coloring is one way of adjusting the color, but may not work well along edges. A semi-transparent shading overlay, with a 'shirt shaped' transparent hole (with anti-aliases skin colored edges where appropriate) may work better.

The next step would be a distortion map to distort patterns and images so as to follow the 3-D curve and bumps of the shirt. such a map can be difficult to make, but is only needed to be created once, just like the mask or the suggested shaped and shaded hole overlay.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

Post Reply