Page 1 of 1

Hald clut identity operation creates color distortion in output

Posted: 2019-08-08T09:26:21-07:00
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?

Re: Hald clut identity operation creates color distortion in output

Posted: 2019-08-08T09:43:10-07:00
by snibgo
For a hald clut, you should use the "-hald-clut" operation, not "-clut". See http://www.imagemagick.org/script/comma ... #hald-clut

Re: Hald clut identity operation creates color distortion in output

Posted: 2019-08-08T09:52:08-07:00
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!

Re: Hald clut identity operation creates color distortion in output

Posted: 2019-08-08T13:39:42-07:00
by fmw42
Your ImageMagick version is ancient (at least 2 years old). Perhaps you should consider upgrading, also.