Page 1 of 1

potential bug with extracting alpha channel IM 6.4.3-7 beta

Posted: 2008-09-15T11:15:43-07:00
by fmw42
IM 6.4.3-7 beta Q16 Mac OSX (Monday beta 3:42 AM)

Trying to extract the alpha channel from:

image.png
Image


convert -verbose info:
...
Depth: 16/8-bit
Channel depth:
red: 1-bit
green: 1-bit
blue: 1-bit
alpha: 8-bit
Channel statistics:
red:
min: 0 (0)
max: 0 (0)
mean: 0 (0)
standard deviation: -0 (-0)
green:
min: 0 (0)
max: 0 (0)
mean: 0 (0)
standard deviation: -0 (-0)
blue:
min: 0 (0)
max: 0 (0)
mean: 0 (0)
standard deviation: -0 (-0)
alpha:
min: 0 (0)
max: 255 (1)
mean: 55.0361 (0.215828)
standard deviation: 103.896 (0.407436)
Alpha: none #0000000000000000


Test:

convert image.png -channel o image_o.png
Image
The above seems fine

Anthony mentioned that -channel a is now different from -channel o. But either it is not working or I am premature in testing it.
convert image.png -channel a image_a.png
Image
This is not different from -channel o

convert image.png -fx "u.a" image_fx_a.png
Image
This is not correct as it should not be transparent. The majority (background) should be black and the letters white.

(get same result with convert image.png -channel rgba -fx "u.a" image_fx_a.png)

identify -verbose image_fx_a.png
...
Depth: 16/8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 8-bit
Channel statistics:
red:
min: 0 (0)
max: 255 (1)
mean: 55.0361 (0.215828)
standard deviation: 103.896 (0.407436)
green:
min: 0 (0)
max: 255 (1)
mean: 55.0361 (0.215828)
standard deviation: 103.896 (0.407436)
blue:
min: 0 (0)
max: 255 (1)
mean: 55.0361 (0.215828)
standard deviation: 103.896 (0.407436)
alpha:
min: 0 (0)
max: 255 (1)
mean: 55.0361 (0.215828)
standard deviation: 103.896 (0.407436)
Alpha: none #0000000000000000


Am I doing something wrong here?


Likewise:

convert image.png -fx "u.o" image_fx_o.png
Image
This is not correct as it should not be transparent. The majority (background) should be white and the letters black.

Again, I apologize if I am testing prematurely

Fred

Re: potential bug with extracting alpha channel IM 6.4.3-7 beta

Posted: 2008-09-15T15:05:08-07:00
by magick
With the latest patch from the Subversion this command works:
  • convert image.png -channel rgba -fx "u.a" -alpha deactivate image_fx_a.png

Re: potential bug with extracting alpha channel IM 6.4.3-7 beta

Posted: 2008-09-15T15:37:54-07:00
by fmw42
magick wrote:With the latest patch from the Subversion this command works:
  • convert image.png -channel rgba -fx "u.a" -alpha deactivate image_fx_a.png
Yes, the above does work as you suggest, even in the current beta.

But would you clarify please.

Why is -alpha deactivate necessary?

I guess I can understand why -channel rgba is needed if -fx by default only works on rgb. Therefore without it, one would get a perfectly opaque white image as -fx would create an opaque alpha to extract. So I guess one needs to add -channel rgba in order for -fx to get the real alpha channel and not generate an opaque one. Is this correct?

BUT, seems to me that -fx "u.a" is very clearly explicit that all it wants is the alpha channel as output as a grayscale image! Adding -alpha deactivate seems a bit strange and potentially more than should be necessary.


Also, what about:

convert image.png -channel a image_a.png

It gives the same results as

convert image.png -channel o image_o.png

Am I premature in testing that?

Re: potential bug with extracting alpha channel IM 6.4.3-7 beta

Posted: 2008-09-15T15:53:49-07:00
by magick
An alpha channel can be overloaded. Sometimes it contains something other than alpha. If the alpha channel is activated it is treated as alpha when resizing or drawing or whatever (alpha-blending). If its deactivated it is treated just like red or green or blue are treated. That is why the user must explicitly state their intentions with -alpha and why we introduced -alpha to begin with.