Page 1 of 1

Extract an Alpha channel

Posted: 2012-08-07T10:08:00-07:00
by lilith
Hi there,

I want to extract an alpha channel from RGBA file.
I used:

Code: Select all

convert -alpha extract "rgba.png" "alpha.png"
or

Code: Select all

convert -separate -channel a "rgba.png" "alpha.png"
It's not what i want.
The file: http://www.hostingpics.net/viewer.php?i ... mized1.png
What it does : http://www.hostingpics.net/viewer.php?i ... 1alpha.png
What i want : http://www.hostingpics.net/viewer.php?i ... ealpha.png

[
Edit:
Zoom:
ImageMagick gives : http://www.hostingpics.net/viewer.php?id=693425zoom.png
I want : http://www.hostingpics.net/viewer.php?i ... omtrue.png
]

Is that possible to get this from IM?
Thanks in advance.

Re: Extract an Alpha channel

Posted: 2012-08-07T10:10:22-07:00
by fmw42
Your IM syntax is not correct for IM 6. try putting the image before the options.

convert "rgba.png" -alpha extract "alpha.png"

The quotes are not really needed unless you have a space in the file names, though it should not hurt to leave them.

see
http://www.imagemagick.org/Usage/basics/#why

Re: Extract an Alpha channel

Posted: 2012-08-07T10:17:07-07:00
by lilith
Hi fmw42,

Your code works too, but it's not what i want.

Thanks,
Greetings.

[
Edit:
ImageMagick gives : http://www.hostingpics.net/viewer.php?id=693425zoom.png
I want : http://www.hostingpics.net/viewer.php?i ... omtrue.png
]

Re: Extract an Alpha channel

Posted: 2012-08-07T12:39:19-07:00
by fmw42
The image you posted has no alpha channel. Perhaps it got removed when uploading or I am not downloading correctly.


Image: 693425zoom.png
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 854x650+0+0
Resolution: 72x72
Print size: 11.8611x9.02778
Units: Undefined
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Red:
min: 0 (0)
max: 255 (1)
mean: 125.438 (0.491913)
standard deviation: 111.795 (0.438412)
kurtosis: -1.88083
skewness: 0.0740597
Green:
min: 0 (0)
max: 255 (1)
mean: 125.438 (0.491913)
standard deviation: 111.795 (0.438412)
kurtosis: -1.88083
skewness: 0.0740597
Blue:
min: 0 (0)
max: 255 (1)
mean: 129.79 (0.508981)
standard deviation: 112.132 (0.439732)
kurtosis: -1.86956
skewness: 0.0383976
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 126.889 (0.497603)
standard deviation: 111.907 (0.438852)
kurtosis: -1.87623
skewness: 0.0622613

Re: Extract an Alpha channel

Posted: 2012-08-07T13:15:57-07:00
by lilith
Hello,

Hum sorry for confusing, but you did not scan the good file:
- The image that uses alpha is here: http://www.hostingpics.net/viewer.php?i ... mized1.png
- Here is the alpha data extracted by ImageMagick : http://www.hostingpics.net/viewer.php?i ... 1alpha.png
- Here is the alpha data extracted by another tool : http://www.hostingpics.net/viewer.php?i ... ealpha.png

Image Magick does not extract alpha correctly, because it seems it destroys some data! The difference is hard to see by eyes, so i zoomed on alpha datas:
- Zoom on alpha data extracted by ImageMagick : http://www.hostingpics.net/viewer.php?id=693425zoom.png
- Zoom on alpha data extracted by another tool : http://www.hostingpics.net/viewer.php?i ... omtrue.png

If i use alpha data extracted by ImageMagick as an alpha channel for the original file, that gives that:
http://www.hostingpics.net/viewer.php?i ... mized2.png

So, it's not the same restitution. There is a problem with alpha extraction, or i do not use the good option.

What i want is to extract alpha from this file:
http://www.hostingpics.net/viewer.php?i ... mized1.png
and get that result:
http://www.hostingpics.net/viewer.php?i ... ealpha.png

And i would like to do this with ImageMagick :)

Thanks for helping,
Greetings.

Re: Extract an Alpha channel

Posted: 2012-08-07T16:17:33-07:00
by fmw42
You do not say what version of IM and platform you are using (or I missed it). But since IM 6.7.8.3 grayscale images have been linear rather than non-linear sRGB. So to get back what you expect you need to add -set colorspace RGB to your command as

convert 2101356optimized1.png -set colorspace RGB -alpha extract 2101356optimized1_alpha.png

This will get you back to what you want.

Re: Extract an Alpha channel

Posted: 2012-08-07T22:12:26-07:00
by lilith
Hello,

I'm using 6.7.8.8.

And thanks, it works perfectly :)
Greetings.

Re: Extract an Alpha channel

Posted: 2012-08-07T22:43:12-07:00
by anthony
Alpha channel is always linear, so I don't know why you need such a convoluted colorspace!

Oh, I get it copying linear alpha into non-linear color channels. Making image RGB first fixes that!