Page 1 of 1

GrayScale to Color

Posted: 2017-05-11T17:13:24-07:00
by TotteKarlsson
Hello,
I'm a beginner user of MagickWand, and also image processing.

I do have grayscale jpeg images that that I would like to 'colorize', i.e. instead of current grayscale I would want a blue, red or perhaps a magenta 'scale'.

Do I need to iterate over individual pixels, or perhaps there is an API function that can do this?

Best Regards,
tk

Re: GrayScale to Color

Posted: 2017-05-11T17:21:39-07:00
by fmw42
In command line, you could use -fill red -colorize 50% or some other percent less than 100% and greater than 0%. I do not know magickwand or any API, but there is likely an equivalent command. See http://www.imagemagick.org/api/magick-i ... orizeImage

Re: GrayScale to Color

Posted: 2017-05-11T17:37:24-07:00
by el_supremo
I'd suggest you first try modifying one of your images using the IM command line. Anthony has several sections about this kind of operation. For example, see the four subsections which start with
Sepia Tone
and then the whole section here:
Recoloring Images with Lookup Tables

Try those methods and if you find a technique that gives you what you want, then you can look at converting the command line into MagickWand code. Whether you will need to iterate over all the pixels depends upon what method is required to achieve the result you want.

Pete

Re: GrayScale to Color

Posted: 2017-05-12T00:44:07-07:00
by snibgo
Most operations at the command line have an equivalent function in both MagickWand and MagickCore. Some command-line operations need calls to a small number of functions.

When designing an image process, it is generally easiest to prototype at the command line. When that does what you want, you can translate it to a program, if you want.

Re: GrayScale to Color

Posted: 2017-05-15T09:57:44-07:00
by TotteKarlsson
fmw42 wrote: 2017-05-11T17:21:39-07:00 In command line, you could use -fill red -colorize 50% or some other percent less than 100% and greater than 0%. I do not know magickwand or any API, but there is likely an equivalent command. See http://www.imagemagick.org/api/magick-i ... orizeImage
Thanks for this reply. I'll check it out and get back with result!

Thanks,
tk

Re: GrayScale to Color

Posted: 2017-05-15T10:20:30-07:00
by TotteKarlsson
Found this example doing exactly what i needed:

viewtopic.php?t=8418