Page 1 of 1

Bug in modulate with HDRI (6.6.0-9)

Posted: 2010-04-11T18:47:50-07:00
by rnbc
Hello!

I've found a bug in modulate that only occurs in HDRI enabled ImageMagick 6.6.0-9 apparently.

convert_hdri input.ppm -modulate 100,150,100 -depth 8 -quality 98 -sampling-factor 1x1 output_hdri.jpg

convert_normal input.ppm -modulate 100,150,100 -depth 8 -quality 98 -sampling-factor 1x1 output_normal.jpg

The input and output files are here:

http://rnbc.dyndns.org/pub/imagemagick_ ... dri.tar.gz

The results:

HDRI:

Image

Normal/16bpp:

Image

The normal version is the one that comes in Ubuntu 9.10:

Version: ImageMagick 6.5.1-0 2009-08-27 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC

The other was compiled by myself with HDRI enabled:

Version: ImageMagick 6.6.0-9 2010-04-03 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: HDRI OpenMP

Re: Bug in modulate with HDRI (6.6.0-9)

Posted: 2010-04-11T21:41:07-07:00
by fmw42
The modulate color space was changed. see http://www.imagemagick.org/Usage/color/ ... colorspace

"Before IM v6.4.0-10 the "-modulate" actually did use HSB color space rather than HSL colorspace. This was changed because of a bug report by a user about the above situation."

"To modulate the image in HSB Color Space, as of IM v6.5.3-7, you can "-set" the 'special' option 'option:modulate:colorspace' with one of the 'Hue' color spaces. EG: HSL, HSB, or HWB."

So be sure you are using the same color space which probably should be HSB to make it the same. Then see if you get the same error.

Re: Bug in modulate with HDRI (6.6.0-9)

Posted: 2010-04-12T03:33:01-07:00
by rnbc
Yes, I get the same error, with all 3 colorspaces...

You can test yourself with the input file I sent. Please tell me if you can't reproduce the result.

This is a problem with hdri-enabled ImageMagick only, just tested ImageMagick-6.6.0-9 with HDRI disabled and it works fine in all colorspaces!

Re: Bug in modulate with HDRI (6.6.0-9)

Posted: 2010-04-12T09:17:48-07:00
by magick
HDRI permits pixel values to go negative or exceed the quantum range. For non-HDRI image formats, you need to clamp the pixel values like this:
  • convert input.ppm -modulate 100,150,100 -clamp -depth 8 -quality 98 -sampling-factor 1x1 output_hdri.jpg

Re: Bug in modulate with HDRI (6.6.0-9)

Posted: 2010-04-12T10:14:36-07:00
by rnbc
I just tested with clamp. In fact with clamp before, after... in generous amounts... to no avail.

Have you tested with the PPM I've put in the first post?

Re: Bug in modulate with HDRI (6.6.0-9)

Posted: 2010-04-12T11:05:13-07:00
by magick
We're using ImageMagick 6.6.1-2 and testing under Linux although it should not matter. We get the blue around the arm rests without the clamp option and get the normal image when we include -clamp on the command line.

Re: Bug in modulate with HDRI (6.6.0-9)

Posted: 2010-04-12T14:49:43-07:00
by rnbc
Ok, it works if -clamp is made exactly before conversion to 8 bits and saving. If I make any other operation, even -auto-level, which presumably normalizes images from 0.0 to 1.0, after -clamp ... if won't work.

Except if I don't use -modulate. Other operations alone and together like -linear-stretch or -gamma or -sigmoidal-contrast work fine without clamp, except if there is a -modulate around.

It's definitely workable, but still a weird behavior :-)

Thanks for the fix guys!

Re: Bug in modulate with HDRI (6.6.0-9)

Posted: 2010-04-12T18:22:40-07:00
by magick
  • It's definitely workable, but still a weird behavior
Agreed. We investigated further and found a bug in the HSL to RGB conversion. We patched ImageMagick 6.6.1-3 Beta to fix the problem. Look for the patch sometime tomorrow. Thanks.

Re: Bug in modulate with HDRI (6.6.0-9)

Posted: 2010-04-12T18:58:04-07:00
by rnbc
Hum... interesting it's only in HSL, because as I wrote previously the error occurred with all 3 colorspaces supported by modulate, unless I was doing something wrong :roll:

I'll check it tomorrow, as soon as I get my hands on that new version ;)

Thanks again for the fast answer! I'm using ImageMagick as part of an HDRI pipeline for image edition on the web (a new PhpBB3 module in fact), and for example a bug I reported in pfstools a few weeks ago is still unanswered. I think they haven't even looked at my mail yet :mrgreen:

Re: Bug in modulate with HDRI (6.6.0-9)

Posted: 2010-04-16T04:28:35-07:00
by rnbc
Ok, the bug in modulate seems solved, now I have another one... in another thread :-?