IM 7.0.5-4 and the "-gamma" operator...

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
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

IM 7.0.5-4 and the "-gamma" operator...

Post by GeeMack »

I'm running IM 7.0.5-4 HDRI on Windows 10 64, trying to make some per-color adjustments using "-gamma", and I'm running into some unexpected behavior. I start with an input image like this...

Image

Then I run it through this command...

Code: Select all

magick input.png ^
   ( -clone 0 -gamma 0.5,1,1 ) ^
   ( -clone 0 -gamma 1,0.5,1 ) ^
   ( -clone 0 -gamma 1,1,0.5 ) +append out_A.png
This is the result...

Image

The left image is unchanged, of course. The second appears to be gamma adjusted across all three RGB channels, while the two on the right are identical to the input. It looks like the first argument to "gamma", the one I understand should act on the red channel, is the only one being recognized, and that argument is applied to all three channels. That doesn't seem right.

Here's a simulation of the behavior I would expect. I apply the "-gamma" operations after activating individual channels with "-channel" like this...

Code: Select all

magick input.png ^
   ( -clone 0 -channel R -gamma 0.5 -channel G -gamma 1 -channel B -gamma 1 ) ^
   ( -clone 0 -channel R -gamma 1 -channel G -gamma 0.5 -channel B -gamma 1 ) ^
   ( -clone 0 -channel R -gamma 1 -channel G -gamma 1 -channel B -gamma 0.5 ) +append out_B.png
The result is what I'd expect from the "-gamma" operations in the first example above...

Image

Setting "-channel" and running the "-gamma" operation on each does make the per-color adjustments, but I'd think using three arguments with the "-gamma" operator should create an identical result, and I'm not getting it. Any ideas?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: IM 7.0.5-4 and the "-gamma" operator...

Post by fmw42 »

I can confirm this bad result using IM 7.0.5.4 Q16 Mac OSX.

However, it works fine in IM 6.9.8.3 Q16 Mac OSX as

Code: Select all

convert input.png \
\( -clone 0 -gamma 0.5,1,1 \) \
\( -clone 0 -gamma 1,0.5,1 \) \
\( -clone 0 -gamma 1,1,0.5 \) +append out_A.png
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: IM 7.0.5-4 and the "-gamma" operator...

Post by GeeMack »

I'm working on some other scripts where this "-gamma" operator would be most useful if it could handle the color channels individually. For now I'm using the "-channel" setting and multiple "-gamma" operations to get around it, and I've been adding a sort of placeholder in the scripts. It works, but it's a little cumbersome that way. It would be helpful to know if this "-gamma" issue is in the queue to be addressed any time soon.
Post Reply