Gamma correcting alpha channel only

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
simon

Gamma correcting alpha channel only

Post by simon »

Using the following command line on an image doesn't result in a correctly gamma corrected alpha channel in the output image.

convert 0001.sgi -channel Alpha -gamma 1.4 test.png

In fact it seems to produce the opposite of what it should, ie it makes the image darker not lighter. If I do -gamma 0.714 (which is 1/1.4) it gets closer but still performs very different to my other imaging package.

Maybe there is different algorithms for doing gamma correction? I thought there was only one.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Gamma correcting alpha channel only

Post by anthony »

The problem is that alpha channel in IM isn't an alpha channel. It is a matte channel whcih is a negated alpha channel

try this...

Code: Select all

   convert 0001.sgi -channel Alpha -negate -gamma 1.4 -negate test.png
this makes the matte channel an alpha, negates it and turns it back into a matte channel ;-)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
simon

Re: Gamma correcting alpha channel only

Post by simon »

Close but still different. It now lightens instead of darkening but the result is still wrong. Ie when I comp the result I see a visible edge where the gamma of the edge pixels in the alpha channel doesn't match the gamma of the main image which was done in a 3D rendering package. I guess there must be different algorithms for gamma. Strange.

I have found another solution for this problem, but I'm still rather curious as to why the results are different in the two packages.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Gamma correcting alpha channel only

Post by anthony »

They should not be different, except to the effects of rounding.
The gamma function is quite well defined.

Is it only an edge that differs or the overall result?

Can you provide an example of the input, command used and the results from Im and the other package?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply