Using lookup table for -fx"". (New user question)

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
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

First of all the IM "txt:" image format only uses intergers and not floating point. so you can not use numbers in the 0.0 to 1.0 range.

You can use numbers from 0 to 255 or 0 to 65535 however (the later
will only work on a Q16 version of IM, not a Q8 ).

Second the header is vital. It first tells IM that this is a "txt:" image
and not a plain text file. also what size, depth and format the image
is using. The order of the pixels however does not matter, or even if all the pixels are defined (undefinaed pixels generally come out as black).

Third, -fx uses values from 0.0 to 1.0 for ALL colors and intensities but uses a rounded off interger for all position and offset locations within images. As such you must scale the color by the length of your LUT to
find the right offset into the image for the replacement color.


For all the details of this, as well as exact formular if you need it, see...
IM Examples, Color Modifications, Color Lookup Tables
http://www.cit.gu.edu.au/~anthony/graph ... #color_lut

Read it carefully, expecially the expert or owl comment at the end of the next "Function to LUT Conversion" section.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

--- 1 ---
That is fine, if your IM txt image header says it uses that value range.

--- 2---
That header appears fine.

--- 3 ---
Yes.

See the IM example link I pointed out above. for LUT usage.

For Txt Image useage see..
http://www.cit.gu.edu.au/~anthony/graph ... files/#txt
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

(1) Assuming "u" gives 0.0 ... 1.0 value:

That is the case, but you have to multiply it by the width of the image.
READ THE EXAMPLES, I pointed you toward!
then you need to convert that to

The result is thus..

Code: Select all

  convert img_low_contr.jpg lut8__little_more_contrast.txt \
            -fx "v.p{u*v.w,0}"  img_low_contr.lmc1_lut8.jpg 
Note you have to multiple the position, NOT the result of the lookup, which is
already a color!!!!

ASIDE: you don't need to specify depth or image type for a '.txt' file.

For absolute correctness, to avoid a rounding issue you use...

Code: Select all

    -fx 'v.p{u*(v.w-.5),0}'
Finally their is a proposal, under discussion (problem how to implement) for a builtin and faster LUT function...
http://www.cit.gu.edu.au/~anthony/graph ... uture/#lut
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

You seem to have fogotten the header describing the IM 'txt' format!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Post the two images somewhere, and I'll download and try to check them out.

Also what version of IM are you using?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Send them to me, Anthony@griffith.edu.au

Lets hope the spam filter doesn't object.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply