Convert with -clut produces different images

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
happy_user103
Posts: 2
Joined: 2011-05-04T06:21:58-07:00
Authentication code: 8675308

Convert with -clut produces different images

Post by happy_user103 »

Hi all,

I have the following problem, possible bug, with coloring a grayscale image using convert and -clut.

On Ubuntu 10.04 with ImageMagick 6.5.7-8 2010-12-02 Q16 the desired conversion works:

Code: Select all

convert in.png colors.png -channel RGBA -clut desired.png
On Ubuntu 10.10 with ImageMagick 6.6.9-5 2011-04-19 Q8 the conversion produces something different:
convert in.png colors.png -channel RGBA -clut wrong.png
Thanks in advance.

The images used and produced:
in.png:
Image

colors.png:
Image

desired.png:
Image

wrong.png:
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert with -clut produces different images

Post by fmw42 »

Your command works fine for me on IM 6.6.9.7 Q16 Mac OSX Tiger.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Convert with -clut produces different images

Post by anthony »

Clut handling of grayscale recolor with involving clut images with alpha, broke in one recent version of IM.

Another programmer (I will not say who) ignored a WARNING I had left in the source code and recoded it incorrectly.

FYI; It is a matter of image processing order in the core library function. Alpha in the clut image has to be recoded first, as it needs to use color value for the lookup (no alpha in input image). Only after alpha is handled can the color values be modified but the CLUT.

I fixed the problem, and re-added the warning, as soon as I discovered it. You must have been unlucky to download a bad version. color values modified before they are used to modify alpha!

Upgrade and all will be well.


ASIDE; Nice way of recoloring so as to represent negative and positive results in a baised grayscale image (perfect gray being regarded as zero).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
happy_user103
Posts: 2
Joined: 2011-05-04T06:21:58-07:00
Authentication code: 8675308

Re: Convert with -clut produces different images

Post by happy_user103 »

After an upgrade to ImageMagick 6.6.9-8 2011-05-05 Q16 on Ubuntu 10.10 convert creates the desired output.

Thank you for your help.
Post Reply