Program for bit plane slicing of Image using Matlab
Bit extraction or Bit Plane Slicing can be defined as separating a digital image into its bit planes is useful for analyzing
the relative importance played by each bit of the image, implying, it
determines the adequacy of numbers of bits used to quantize each pixel ,
useful for image compression.
For example, for 8-bit
data representation there are 8 bit planes: the first bit plane
contains the set of the most significant bit, and the 8th contains the
least significant bit.
Program:
clc;
a=imread('D:\bird.jpg');
c=rgb2gray(a);
a=double(c);
r=input('which bit of image do you want to
see MSB=1 LSB=8 :');
[row col]=size(a);
for x=1:1:row
for
y=1:1:col
c=dec2bin(a(x,y),8);
d=c(r);
w(x,y)=double(d);
if w(x,y)==49
w(x,y)==255;
else
w(x,y)=0;
end
end
end
figure(1)
title('Original Image')
figure(2)
imshow(uint8(w))
title('Bit extraction')
xlabel(sprintf('Bit value is %g',r))
OUTPUT:
No comments:
Post a Comment