Convert black-white image to blue-red

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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert black-white image to blue-red

Post by fmw42 »

werty wrote:Hi, I have black&white bitmap, and I need convert it to blue&red, not just change color (black -> blue, white -> red), but all gray gradient. I hope it's clear...

I found 'convert -recolor <matrix>', but I have no idea, how make that transform matrix.

Thanks Radek

Post an example image of your input and desired output (if you have one).

What is not clear is how you want to separate the grayshades into blue and red? Do you want all graylevels below midgray to be blue and all graylevels above midgray to be red? What is the functionality you desire?

Here is one way, but I do not know if this is what you want:

Create gradient:
convert -size 100x100 gradient: grad.png
Image

Change graylevels from b/w to blue/red
convert grad.png +level-colors blue,red grad_blue_red.png
Image

Change graylevels from b/w to red/blue
convert grad.png +level-colors red,blue grad_red_blue.png
Image
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Convert black-white image to blue-red

Post by anthony »

Not however the +level-colors is a new addition to IM. A very useful one. The alternative to this is to either use -clut or a -fx equivelent function. Both methods are also looked at in IM examples, Color Modification
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply