Colorizing a Greyscale image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
myspacee
Posts: 153
Joined: 2007-06-14T02:09:35-07:00

Colorizing a Greyscale image

Post by myspacee »

Hello,
have not luck to search how colorizing a Greyscale image.

For sure this question have be done many times.

Find posts about map, tinting, , RGB, but not the solution to colorize 256 greyscale image :
Image
http://www.webalice.it/t.bavaro/colorizing_03.gif

Is there any way to obtain this effect ?

Thank you ,

m.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Colorizing a Greyscale image

Post by snibgo »

Many of the tones in the skin, boots and floor are the same. So you would need to create masks to distinguish between them.
snibgo's IM pages: im.snibgo.com
myspacee
Posts: 153
Joined: 2007-06-14T02:09:35-07:00

Re: Colorizing a Greyscale image

Post by myspacee »

thank you for reply,
any example or link ?

understand only that i must 'link' one of 256 grayscale tones to one of 256 RGB ones....

see some examples that call a .txt file, any other info about this ?

Thank you for any info,

m.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Colorizing a Greyscale image

Post by snibgo »

But in your sample, some gray tones become pink tones (skin) or brown tones (boots) or nearly gray tones (floor). For example, gray (67,67,67) occurs in skin, floor and boots.
snibgo's IM pages: im.snibgo.com
myspacee
Posts: 153
Joined: 2007-06-14T02:09:35-07:00

Re: Colorizing a Greyscale image

Post by myspacee »

forgot my example. Not IM generated, but photoshopped.

i'm searching base exaple made in IMt o start mapping greyscale to RGB color.

For what i see, must is possible to 'map' grey tones to RGB and let IM to change
greyscale tone with relative RGB.

right ?

m.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Colorizing a Greyscale image

Post by snibgo »

Ah, perhaps you want "color lookup tables": http://www.imagemagick.org/Usage/color/#clut
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Colorizing a Greyscale image

Post by fmw42 »

You could also try my script, mapcolors at the link below. But it will be slow if you have to do it on 256 grayscale values to different colors.

A look-up table with -clut will be fast, but you still need to set up the mapping for each of the 256 grayscales to some color.

The problem with the above is that there is no guarantee that the same gray shade will be needed to colorize more than one area with different colors.

You could also create masks for each different colored area, then tint or colorize the grayscale image differently for each color needed, then composite all the tinted images back into one image using each of the masks. see http://www.imagemagick.org/Usage/color/#tinting and http://www.imagemagick.org/Usage/channels/#masks and http://www.imagemagick.org/Usage/compose/ and http://www.imagemagick.org/Usage/layers/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Colorizing a Greyscale image

Post by anthony »

My suggestion is that you want to preserve the greyscale intensity of the image.

So first divide the image into the areas that get different colors (skin, boots etc), then use -modulate and -tint on the different areas before recombining.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply