Bug in modulate with HDRI (6.6.0-9)

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
rnbc
Posts: 109
Joined: 2010-04-11T18:27:46-07:00
Authentication code: 8675308

Bug in modulate with HDRI (6.6.0-9)

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
rnbc
Posts: 109
Joined: 2010-04-11T18:27:46-07:00
Authentication code: 8675308

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

Post 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!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

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

Post 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
rnbc
Posts: 109
Joined: 2010-04-11T18:27:46-07:00
Authentication code: 8675308

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

Post 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?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

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

Post 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.
rnbc
Posts: 109
Joined: 2010-04-11T18:27:46-07:00
Authentication code: 8675308

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

Post 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!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

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

Post 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.
rnbc
Posts: 109
Joined: 2010-04-11T18:27:46-07:00
Authentication code: 8675308

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

Post 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:
rnbc
Posts: 109
Joined: 2010-04-11T18:27:46-07:00
Authentication code: 8675308

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

Post by rnbc »

Ok, the bug in modulate seems solved, now I have another one... in another thread :-?
Post Reply