GrayScale to Color

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
TotteKarlsson
Posts: 3
Joined: 2017-05-11T16:20:59-07:00
Authentication code: 1151

GrayScale to Color

Post by TotteKarlsson » 2017-05-11T17:13:24-07:00

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

User avatar
fmw42
Posts: 22081
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: GrayScale to Color

Post by fmw42 » 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

el_supremo
Posts: 1017
Joined: 2005-03-21T21:16:57-07:00

Re: GrayScale to Color

Post by el_supremo » 2017-05-11T17:37:24-07:00

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
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.

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

Re: GrayScale to Color

Post by snibgo » 2017-05-12T00:44:07-07:00

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.
snibgo's IM pages: im.snibgo.com

TotteKarlsson
Posts: 3
Joined: 2017-05-11T16:20:59-07:00
Authentication code: 1151

Re: GrayScale to Color

Post by TotteKarlsson » 2017-05-15T09:57:44-07:00

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

TotteKarlsson
Posts: 3
Joined: 2017-05-11T16:20:59-07:00
Authentication code: 1151

Re: GrayScale to Color

Post by TotteKarlsson » 2017-05-15T10:20:30-07:00

Found this example doing exactly what i needed:

viewtopic.php?t=8418

Post Reply