Hald clut identity operation creates color distortion in output

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
modem_down
Posts: 3
Joined: 2019-08-08T08:36:16-07:00
Authentication code: 1152

Hald clut identity operation creates color distortion in output

Post by modem_down »

Steps to reproduce

First, which version of ImageMagick am I using?

Code: Select all

$ convert --version
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP 
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png tiff wmf x xml zlib
Generate a source image to which we will later apply a clut operation:

Code: Select all

$ convert -size 256x256 gradient:red1-green1 -colorspace RGB original.png
Generate a unity (i.e. identity) hald file:

Code: Select all

$ convert hald:16 hald16.png
Apply the identity hald file to the source image:

Code: Select all

$ convert original.png hald16.png -clut result.png
Expected result

result.png should look identical (or at least nearly so, allowing for rounding errors or interpolation) to original.png.

Actual result

result.png looks different to original.png. original.png has a smooth gradient from red to green. result.png looks like a psychedelic barcode: instead of a smooth gradient, it has bands of red, bands of green, and bands of black.

Is this a bug in that version of ImageMagick, or have I done something wrong?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Hald clut identity operation creates color distortion in output

Post by snibgo »

For a hald clut, you should use the "-hald-clut" operation, not "-clut". See http://www.imagemagick.org/script/comma ... #hald-clut
snibgo's IM pages: im.snibgo.com
modem_down
Posts: 3
Joined: 2019-08-08T08:36:16-07:00
Authentication code: 1152

Re: Hald clut identity operation creates color distortion in output

Post by modem_down »

snibgo wrote: 2019-08-08T09:43:10-07:00 For a hald clut, you should use the "-hald-clut" operation, not "-clut". See http://www.imagemagick.org/script/comma ... #hald-clut
Silly me. Thank you!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Hald clut identity operation creates color distortion in output

Post by fmw42 »

Your ImageMagick version is ancient (at least 2 years old). Perhaps you should consider upgrading, also.
Post Reply