MATLAB: How to construct a binary image based on the most significant bit of the pixels

msboctave

The brightness intensity of the image fractal.jpg takes values between 0 and 255.Thus each pixel of the image can be represented with 8 bits.Since we have the image, how can i construct a binary image based on the most significant bit of the pixels.Specifically , if the MSB of a pixel is 1 , the pixel in the new image will take 255 , while if it is 0 ,the pixel in the new image will take value 0 .Repeat for the second most significant bit and the least significant bit (least significant bit, LSB). I have to implement this in Octave.

Best Answer

For a gray scale image (not color), you can use bitget:
% Compute the bit plane image.
bitPlaneImage = bitget(grayImage, bp+1);
For a full demo, see my attached demo.
Related Question