Page 1 of 1

Determine transparent pixels and generate alpha channel

Posted: 2010-11-16T12:46:36-07:00
by mhoehn@hotmail.de
Is there a command line sequence that let me figure out if an image has fully transparent pixels?
And is it possible to generate an alpha channel for this image where all fully transparent pixels are black and all solid pixels are white?
It should be possible that semi transparent pixels should get gray in the alpha channel. The more a pixel is transparent in the image the darker the gray level for the representing pixel in the alpha channel should be.

Re: Determine transparent pixels and generate alpha channel

Posted: 2010-11-16T13:48:44-07:00
by GreenKoopa
mhoehn@hotmail.de wrote: And is it possible to generate an alpha channel for this image where all fully transparent pixels are black and all solid pixels are white?
It should be possible that semi transparent pixels should get gray in the alpha channel. The more a pixel is transparent in the image the darker the gray level for the representing pixel in the alpha channel should be.
Two of many options:

Code: Select all

convert in.png -alpha extract alpha1.png
convert in.png -channel matte -separate +channel -negate alpha2.png
mhoehn@hotmail.de wrote: Is there a command line sequence that let me figure out if an image has fully transparent pixels?
I'm not clear what form you would like the answer to take. Here is one option that gives you a count of the fully transparent pixels:

Code: Select all

convert alpha1.png -threshold 0 -format "%c" histogram:info: