Page 1 of 2
Change color of images without changing the texture
Posted: 2016-04-18T19:22:22-07:00
by Son13
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!
Re: Change color of images without changing the texture
Posted: 2016-04-18T19:33:04-07:00
by fmw42
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
Code: Select all
convert image -colorspace gray +level-colors black,red result
or
Code: Select all
convert image -colorspace gray +level-colors red,white result
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.
Re: Change color of images without changing the texture
Posted: 2016-04-18T19:45:08-07:00
by Son13
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.
Re: Change color of images without changing the texture
Posted: 2016-04-18T19:56:02-07:00
by fmw42
I think you may need to separate each texture pattern into its own image, then perhaps do something like (untested):
Code: Select all
convert texture -colorspace gray -equalize +level-colors black,red result
or
Unix syntax:
Code: Select all
convert \( texture -colorspace gray -equalize \) \( -clone 0 -fill red -colorize 100 \) -compose multiply -composite result
or
Code: Select all
convert \( texture -colorspace gray -equalize \) \( -clone 0 -fill red -colorize 100 \) \( -clone 0 \) -compose multiply -composite result
For -equalize to work effectively to "equalize" each texture, it needs to process each texture separately.
Re: Change color of images without changing the texture
Posted: 2016-04-18T20:00:57-07:00
by fmw42
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
Re: Change color of images without changing the texture
Posted: 2016-04-18T20:05:02-07:00
by snibgo
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.
Re: Change color of images without changing the texture
Posted: 2016-04-18T20:14:52-07:00
by fmw42
I think he wants to "equalize" the light/dark striping of each texture to the same brightness/contrast before coloring it.
Re: Change color of images without changing the texture
Posted: 2016-04-18T20:21:51-07:00
by snibgo
Quite possibly. Or perhaps he wants the samples to have the same average intensity while retaining different contrasts. "-auto-gamma" will do that.
Re: Change color of images without changing the texture
Posted: 2016-04-18T20:28:07-07:00
by Son13
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..
Re: Change color of images without changing the texture
Posted: 2016-04-18T20:42:30-07:00
by snibgo
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.
Re: Change color of images without changing the texture
Posted: 2016-04-18T21:18:14-07:00
by Son13
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!
Re: Change color of images without changing the texture
Posted: 2016-04-18T21:24:07-07:00
by fmw42
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
Posted: 2016-04-18T21:44:30-07:00
by Son13
Re: Change color of images without changing the texture
Posted: 2016-04-18T22:18:22-07:00
by fmw42
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
Re: Change color of images without changing the texture
Posted: 2016-04-19T06:15:24-07:00
by snibgo
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.