I believe there is a bug in RecolorImage() in fx.c when calculating opacity.
For an order 5 matrix, the code calculates opacity as:
recolor_pixel.opacity=(MagickRealType) QuantumRange-k[15]*pixel.red+
k[16]*pixel.green+k[17]*pixel.blue+k[18]*(QuantumRange-
pixel.opacity)+k[23]*QuantumRange;
So for a matrix like this:
00 01 02 03 04
05 06 07 08 09
10 11 12 13 14
15 16 17 18 19
20 21 22 23 24
opacity = QuantumRange - 15R + 16G + 17B + 18A + 23
But I think it's either missing a set of parentheses or needs minuses instead
of all the pluses:
opacity = QuantumRange - ( 15R + 16G + 17B + 18A + 23 )
opacity = QuantumRange - 15R - 16G - 17B - 18A - 23
If I adjust my matrix so that the G, B, and A channel weights and the constant
are negative from what I want, then it works as expected. (That is, it works
as I would expect it to work without my changing the signs on my matrix.)
The same bug appears to be in the order 6 matrix for CMYKA.
I'm using the following version, but the above code is from ImageMagick 6.4.1
Version: ImageMagick 6.3.7 02/19/08 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2008 ImageMagick Studio LLC
Bug in RecolorImage() when calculating alpha channel
-
- Posts: 6
- Joined: 2008-05-15T04:06:34-07:00
Re: Bug in RecolorImage() when calculating alpha channel
We have a patch for the problem you reported in ImageMagick 6.4.1-4 Beta available sometime tomorrow.