Bit plane extraction

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
yellow
Posts: 28
Joined: 2011-06-15T14:01:24-07:00
Authentication code: 8675308

Bit plane extraction

Post by yellow »

Hi

Is it possible in IM to extract the 8 bit planes within an 8bit image to individual .png images for analysis?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Bit plane extraction

Post by anthony »

Note simply or fast but it should be possible using the bit operations of -fx

Hmmm... Extract the upper most bitplane..

convert rose: -fx '(int(u*255)&128)/255' show:
convert rose: -fx '(int(u*255)&64)/255' show:
convert rose: -fx '(int(u*255)&32)/255' show:


If you want them brighter you can either adjust the division (return color value back to normailised 0 to 1 range)
or just use -auto-level to spread the values to maximum values.

Of course the less significant bitplanes looks more and more randomized.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
yellow
Posts: 28
Joined: 2011-06-15T14:01:24-07:00
Authentication code: 8675308

Re: Bit plane extraction

Post by yellow »

anthony, thank you again :-)

Am I right in using 256,128,64,32,16,8,4,2 ? Stupid question using 256 gives me as error, I get a 256kb frame rather than 6mb, using 255 gives me what appears to be full image data, I'd expect to see regular gaps to the histogram on MSB, where data from the lower planes would be missing.

Should there be a 256 in the IM commands above or am I just not understanding. :-)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Bit plane extraction

Post by anthony »

You need to remember that when normalized the value is 0.0 to 1.0 but when using interger (quantums) it is 0 to 255.

In other words 255 (2^n-1) should be the right value.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply