Lookup table for input/output value changes?

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
rkw

Lookup table for input/output value changes?

Post by rkw »

I'm looking for a way to change a floating point TIFF to an indexed PNG. I need this done in a batch way, so that all input TIFFs are indexed with the same output values. The input images are all single-band.

Is there a way to use a lookup table in ImageMagick that provides min/max input values, along with the output number?

Example:

input range:output value
0.0-1.534:0
1.535-24.3922:1
25.3923-100.328:2
etc....

such that if a pixel has a source value of 10.23 the output value would be 1

Thanks in advance!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Lookup table for input/output value changes?

Post by fmw42 »

see my unix bash script, plm at the link below

Note that for Q8 or Q16 IM compiles, grayscale values in IM are, repsectively, integers 0-255 or 0-65535. You can also use floats 0-100%.

The other way you can try to do it is using a set of -fx ternary conditional commands or possibly one long set of nested ternary conditional commands in one -fx statement. see http://www.imagemagick.org/script/fx.php

Note within -fx, graylevels are in the range of floats 0 to 1.


In order to use floating point Tiffs you must compile IM in HDRI mode; otherwise your tif will get truncated to integer values in whatever Q level you compile IM. see http://www.imagemagick.org/Usage/basics/#depth and http://www.imagemagick.org/script/high- ... -range.php
rkw

Re: Lookup table for input/output value changes?

Post by rkw »

Thanks! The fx command looks like what I need - I should be able to get what I need done through a series of conditions.

Now I just need to get IM compiled correctly for hdri - my initial attempts are failing under cygwin.
Post Reply