im_in=imread('peppers512.tif');
im_in=double(im_in);

L=8;
[size_r,size_c]=size(im_in);
im_size=size_r*size_c;
im_vec=reshape(im_in,1,im_size);
%M=length(im_vec);
%bit_vec=[];
%for m=1:M
%    bit_vec=[bit_vec bitget(im_vec(m),L:-1:1)];
%end

x =0:255;
hist(im_vec,x)

n= histc(im_vec,x);
p=n./(512*512);

figure;
colormap(gray);
h=image(im_in);
set(h,'CDataMapping','scaled')
axis('equal');

        