I want to take an RGBA png input, extract the G & B channels, and pack them into a single 8-bit grayscale image. In other words the final 8-bit grayscale PNG output has the source Green channel packed into the lower 4 bits, the Blue channel packed into the upper 4 bits.
I can see how to extract the G and B channels as grayscale, but I'm stuck on scaling/biasing the channels to pack them together. Does anyone know if this is possible using the command line?
Cheers, Noel
Pack color channels into grayscale
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Pack color channels into grayscale
It can probably be done entirely within IM, but possibly very messy. The easiest way would be to process the image in a script, C program or whatever.
Something similar was asked in this forum not long ago: viewtopic.php?f=2&t=23199
Something similar was asked in this forum not long ago: viewtopic.php?f=2&t=23199
snibgo's IM pages: im.snibgo.com
Re: Pack color channels into grayscale
Thanks for the info. Looks like it'll be easier to write a standalone tool for this!
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Pack color channels into grayscale
Yes, I think so. The RAW: and TXT: formats are easy to read and write. See http://www.imagemagick.org/Usage/files/#txt and http://www.imagemagick.org/Usage/formats/#rgb . Or PBM: http://www.imagemagick.org/Usage/formats/#pbmplus .
A C program to do what you want would be almost trivial.
A C program to do what you want would be almost trivial.
snibgo's IM pages: im.snibgo.com