Page 1 of 1

Colorizing images

Posted: 2008-10-23T16:04:59-07:00
by kriko
Hello!

I have a bunch of images like this:
Image

and I would like to chage their colours, basically just replacing blue shades.
I experimented a bit from wiki, but the closest I got is this:

Code: Select all

convert cal_newevent.gif -fill orange -tint 110 tint.png
Image

Which is not really good. I'm not even sure how is this operation called properly (tint, colorize?) - I'm new to graphics.
Can someone give me some hints for solving this problem?

Thanks!

Re: Colorizing images

Posted: 2008-10-23T18:49:54-07:00
by fmw42
kriko wrote:Hello!

I have a bunch of images like this:
Image

and I would like to chage their colours, basically just replacing blue shades.
I experimented a bit from wiki, but the closest I got is this:

Code: Select all

convert cal_newevent.gif -fill orange -tint 110 tint.png
Image

Which is not really good. I'm not even sure how is this operation called properly (tint, colorize?) - I'm new to graphics.
Can someone give me some hints for solving this problem?

Thanks!
You can use the IM function -modulate to rotate the colors (by changing the hue in HSB colorspace)

convert calnewevent.gif -modulate 100,100,50 calnewevent_green.gif

where the 3 numbers are brightness, saturation and hue. 100 means no change. You may have to play with the third number to get the color you want as the results seem to depend upon what color your image is to begin with.

When I used 50, the result was a green color. When I used 0, the result was kind of yellow brown. When I used 150 (or -50), the result was magenta


see:
http://www.imagemagick.org/script/comma ... p#modulate
http://en.wikipedia.org/wiki/HSL_color_space

Re: Colorizing images

Posted: 2008-10-24T06:55:44-07:00
by kriko
Thank you!
That was exactly what I was looking for.

Re: Colorizing images

Posted: 2008-10-26T11:46:22-07:00
by Bonzo
I have been modifying a forum and this could have saved me a lot of time if I had known about it before. I will remember it the next time I do it :D

Re: Colorizing images

Posted: 2008-10-27T00:08:51-07:00
by anthony
It is a good idea for this type of work for the images to first be mapped to grayscale, and then to a red scale. After that rotations
can be coordinated for multiple images and hues (with red at 100)

Alternativally the grayscale version can be re-maped using the newer operator +level-colors ,{color}
The ',' is important as it means the first color will be the normal 'black' default, and you are only wanting to remap the white color.

for example try....

Code: Select all

convert image.png -colorspace gray +level-colors ,purple  image_purple.png
See IM examples, color modifications, Level Adjustment by Color
http://www.imagemagick.org/Usage/color/#level-colors

Especially if you wait a day or so for the new examples I just added.

Re: Colorizing images

Posted: 2008-10-27T00:43:36-07:00
by kriko
Thank you, I'll take a look.

Re: Colorizing images

Posted: 2008-10-27T01:00:52-07:00
by anthony
Looking at your image again you have both black and white in your image you will want to preserve. What you wnt is to map the mid-gray color of a pure grayscale image (-colorspace gray) using -tint.

So you almost had it right, you just needed to remove the old mid-tone color back to a grey first. You can also adjust the gray as well using -tint with a gray color to get the base image right.

Re: Colorizing images

Posted: 2008-10-27T12:41:38-07:00
by kriko

Code: Select all

for i in * ; do convert $i -tint gray +level-colors purple $i; done
convert: invalid argument for option `gray': -tint.

Are you sure it is right?

Re: Colorizing images

Posted: 2008-10-27T13:39:01-07:00
by fmw42
kriko wrote:

Code: Select all

for i in * ; do convert $i -tint gray +level-colors purple $i; done
convert: invalid argument for option `gray': -tint.
Are you sure it is right?
Check your IM version. level-colors was made available only at IM v6.2.4-1

Re: Colorizing images

Posted: 2008-10-27T13:42:11-07:00
by kriko
I upgraded imagemagick and now it's fine. I'm getting better and better results, currently using parameters:

Code: Select all

convert cal_addevent.gif -colorspace gray -tint 40 +level-colors red, alpha.gif
Update: this sample seems to be perfect for my needs:

Code: Select all

for i in * ; do convert $i -colorspace gray -fill "rgb(100,150,110)" -tint 110 $i; done;
Thank you guys for all help!

Re: Colorizing images

Posted: 2008-10-27T22:29:40-07:00
by anthony
kriko wrote:I upgraded imagemagick and now it's fine. I'm getting better and better results, currently using parameters:

Code: Select all

convert cal_addevent.gif -colorspace gray -tint 40 +level-colors red, alpha.gif
Update: this sample seems to be perfect for my needs:

Code: Select all

for i in * ; do convert $i -colorspace gray -fill "rgb(100,150,110)" -tint 110 $i; done;
Thank you guys for all help!
You better make sure you set the fill color before tinting, like you di for your second example.

If you tint the image with pure red, then you can use -modulate to rotate the colors through the spectrum to produce a range of different colored images.