Tuesday, November 17, 2009

To perform Bit Plane slicing of a monochrome / 16 / 24 bit bitmap / JPEG / TIFF / GIF / Color image

Note:-Write this code in Matlab

CODE

%Bit plane slicing

clear all ;
clc;
a=imread('saturn.tif');
a=double(a);
r=input('Which Bit Image Do You Want To See 1=MSB 8=LSB');
[row,col]=size(a);
for x=1:1:row
for y=1:1:col
c=dec2bin(a(x,y),8);%Converts Decimal To Binary
d=c(r);
w(x,y)=double(d);%%Since w is Char and cannot Be Plotted
if w(x,y)==49%%Since Double Of d will be either 49 or 48
w(x,y)=255;
else
w(x,y)=0;
end
end
end
figure(1);
imshow(uint8(a));
figure(2);
imshow(uint8(w));

1 comment:

  1. how can we reverse this? as in join the bit-planes to obtain original image?

    ReplyDelete