Page 1 of 1

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

Posted: 2017-04-09T17:02:53-07:00
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?

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

Posted: 2017-04-09T17:22:33-07:00
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

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

Posted: 2017-04-16T16:49:13-07:00
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.