Change color of images without changing the texture
Change color of images without changing the texture
May be this can be a simple thing for you experts hence reaching out.
I have a color chart with different texture formats as referred http://beckerlelumber.com/zar.htm
Is it possible to change the color for each of these sample to one color (say, RED) without changing the texture. Again, the same shade of RED should be applied to each of this chart except preserving the texture.
It will be good to have a BATCH command where one sample from the chart is passed as an input image and changed it to RED. Thanks for your time!
I have a color chart with different texture formats as referred http://beckerlelumber.com/zar.htm
Is it possible to change the color for each of these sample to one color (say, RED) without changing the texture. Again, the same shade of RED should be applied to each of this chart except preserving the texture.
It will be good to have a BATCH command where one sample from the chart is passed as an input image and changed it to RED. Thanks for your time!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Change color of images without changing the texture
Please always provide your IM version and Platform, since syntax may differ. Are you trying to simple add some red or convert the whole pattern to red on top of the texture. If the latter, then
or
Are you trying to convert this whole image or just each texture pattern in the image?
Please be more specific about what you want to do or provide an input and output example.
Code: Select all
convert image -colorspace gray +level-colors black,red result
Code: Select all
convert image -colorspace gray +level-colors red,white result
Please be more specific about what you want to do or provide an input and output example.
Re: Change color of images without changing the texture
Hi fmw42:
Thanks for your quick response. I have tried these commands earlier and rechecked again... the resultant images color don't get the same RED color even though the texture is maintained.
One texture image is passed at a time.
Note: I have PNG images and not sure if that makes a difference. The darker colors images result into darker shade of RED and lighter color images result into lighted shade of RED and this is what I am trying to overcome. It will be great to have same SHADE of RED but it also preserves the texture.
Thanks for your quick response. I have tried these commands earlier and rechecked again... the resultant images color don't get the same RED color even though the texture is maintained.
One texture image is passed at a time.
Note: I have PNG images and not sure if that makes a difference. The darker colors images result into darker shade of RED and lighter color images result into lighted shade of RED and this is what I am trying to overcome. It will be great to have same SHADE of RED but it also preserves the texture.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Change color of images without changing the texture
I think you may need to separate each texture pattern into its own image, then perhaps do something like (untested):
or
Unix syntax:
or
For -equalize to work effectively to "equalize" each texture, it needs to process each texture separately.
Code: Select all
convert texture -colorspace gray -equalize +level-colors black,red result
Unix syntax:
Code: Select all
convert \( texture -colorspace gray -equalize \) \( -clone 0 -fill red -colorize 100 \) -compose multiply -composite result
Code: Select all
convert \( texture -colorspace gray -equalize \) \( -clone 0 -fill red -colorize 100 \) \( -clone 0 \) -compose multiply -composite result
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Change color of images without changing the texture
The other thing you could do besides -equalize, would be to convert each image to the same brightness and contrast using the mean and std statistics. See snibgo's web site for details at http://im.snibgo.com/gainbias.htm
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Change color of images without changing the texture
There are many methods to re-colour an image while keeping the texture. In terms of HSL, perhaps you want a constant hue but varying lightness and saturation. If so, just convert to HSL, set the hue, and convert back.
Or you could convert it to grayscale, then "-tint" or "-colorize" it.
Or you could make a Gaussian pyramid, recolour the top layer with your chosen colour, and collapse it.
Without understanding your goals, advice is difficult.
Or you could convert it to grayscale, then "-tint" or "-colorize" it.
Or you could make a Gaussian pyramid, recolour the top layer with your chosen colour, and collapse it.
Without understanding your goals, advice is difficult.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Change color of images without changing the texture
I think he wants to "equalize" the light/dark striping of each texture to the same brightness/contrast before coloring it.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Change color of images without changing the texture
Quite possibly. Or perhaps he wants the samples to have the same average intensity while retaining different contrasts. "-auto-gamma" will do that.
snibgo's IM pages: im.snibgo.com
Re: Change color of images without changing the texture
Hi FNW42 & Snibgo:
Thanks for the options that you guys have provided.
Just to restate the goal...
1. Its a web application and the user is allowed to select couple of images (with varied range of color & texture http://beckerlelumber.com/zar.htm)
2. User select the new color, say RED
3. The updated two images are compare - The problem I am currently facing is the darker colors images(No 4 http://beckerlelumber.com/zar.htm) result into darker shade of RED and lighter color images(No 8 http://beckerlelumber.com/zar.htm) result into lighted shade of RED.
I would like to have the same SHADE of RED for both darker and lighter input images..
Thanks for the options that you guys have provided.
Just to restate the goal...
1. Its a web application and the user is allowed to select couple of images (with varied range of color & texture http://beckerlelumber.com/zar.htm)
2. User select the new color, say RED
3. The updated two images are compare - The problem I am currently facing is the darker colors images(No 4 http://beckerlelumber.com/zar.htm) result into darker shade of RED and lighter color images(No 8 http://beckerlelumber.com/zar.htm) result into lighted shade of RED.
I would like to have the same SHADE of RED for both darker and lighter input images..
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Change color of images without changing the texture
So, "-equalize" or "-auto-gamma".
But you'll have to do this for each image separately. You can't do it to one image that contains multiple samples. And each image must contain only the sample, without any borders.
But you'll have to do this for each image separately. You can't do it to one image that contains multiple samples. And each image must contain only the sample, without any borders.
snibgo's IM pages: im.snibgo.com
Re: Change color of images without changing the texture
As directed, took one image separately and tried the below commands with -equalize & -auto-gamma. The resultant images lose their texture even though the color is the same.
convert 4.png +level-colors #FF0000 -equalize 41.png
convert 4.png +level-colors #FF0000 -auto-gamma 41.png
With this command, the texture is maintained perfectly but the color is not the same.
convert 4.png +level-colors #FF0000, white -equalize 41.png
convert 4.png +level-colors #FF0000, white -auto-gamma 41.png
Please suggest for any changes. Thanks again!
convert 4.png +level-colors #FF0000 -equalize 41.png
convert 4.png +level-colors #FF0000 -auto-gamma 41.png
With this command, the texture is maintained perfectly but the color is not the same.
convert 4.png +level-colors #FF0000, white -equalize 41.png
convert 4.png +level-colors #FF0000, white -auto-gamma 41.png
Please suggest for any changes. Thanks again!
Last edited by Son13 on 2016-04-18T21:25:39-07:00, edited 1 time in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Change color of images without changing the texture
Please provide the 4.png image and others that you want to make the same red. We need to be able to reproduce your results and see what you have done. You can post images to some free hosting service such as dropbox.com and put the URLs here.
Re: Change color of images without changing the texture
Here, are the sample images:
Set 1:
https://www.dropbox.com/s/vgqvgfh4oi6eci9/4.png?dl=0
https://www.dropbox.com/s/3gbc3xcjtuav5lh/8.png?dl=0
Set 2: Different sample with white background, using (convert 3.png +level-colors #FF0000, white -equalize 31.png)
https://www.dropbox.com/s/mzd66hscv4njg8d/3.png?dl=0
https://www.dropbox.com/s/0finrl3539i7zwd/2.png?dl=0
Set 1:
https://www.dropbox.com/s/vgqvgfh4oi6eci9/4.png?dl=0
https://www.dropbox.com/s/3gbc3xcjtuav5lh/8.png?dl=0
Set 2: Different sample with white background, using (convert 3.png +level-colors #FF0000, white -equalize 31.png)
https://www.dropbox.com/s/mzd66hscv4njg8d/3.png?dl=0
https://www.dropbox.com/s/0finrl3539i7zwd/2.png?dl=0
Last edited by Son13 on 2016-04-19T06:58:57-07:00, edited 1 time in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Change color of images without changing the texture
4.png and 41.png are quite different. The latter is completely red. So I am confused. If you want two different textures to be the same color, then provide two different texture images, so we can test methods.
On your wig images, you will need to make the background transparent or the white will change. You probably want to use two different shades of red in via +level-colors or via a clut with two or more shades of red. See http://www.imagemagick.org/Usage/color_mods/#clut and http://www.imagemagick.org/Usage/color_mods/#duotone
On your wig images, you will need to make the background transparent or the white will change. You probably want to use two different shades of red in via +level-colors or via a clut with two or more shades of red. See http://www.imagemagick.org/Usage/color_mods/#clut and http://www.imagemagick.org/Usage/color_mods/#duotone
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Change color of images without changing the texture
Code: Select all
convert 4.png -colorspace gray -auto-level +level-colors red,white wood1.png
Code: Select all
convert 4.png -colorspace gray -auto-level +level-colors black,red wood2.png
I don't know what effect you are aiming at.
snibgo's IM pages: im.snibgo.com