How to apply color palette to a grayscale 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
RDalmagro
Posts: 1
Joined: 2014-03-26T07:53:20-07:00
Authentication code: 6789

How to apply color palette to a grayscale image

Post by RDalmagro »

Hi
I am working with satellite images (an 8-bit grayscale TIFF file), and I am trying to apply it a color palette using IM. The problem is that I need to set a color different ranges of values, for example red for value between 35-65 and blue between 70-75.
I would like some help about this.
Thanks

_____________________________

http://www.realvirtual.com.mx
Last edited by RDalmagro on 2014-04-03T06:14:39-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to apply color palette to a grayscale image

Post by snibgo »

One way of doing this is to make a CLUT (colour look-up table), which can then be used for many source images. Windows BAT syntax:

Code: Select all

convert ^
  -size 1x256 gradient: -rotate 90 ^
  -fx "u>=35/255&&u<=65/255?red:u" ^
  -fx "u>=70/255&&u<=75/255?blue:u" ^
  clutfile.png
Then each image can be processed:

Code: Select all

convert in.tiff clutfile.png -clut out.tiff
snibgo's IM pages: im.snibgo.com
Post Reply