% Load Lenna image and then quantise to required precision

% quantiser_demo
% cd c:\jl\4F8_ImageProcessing\ImageProcessing2\ImageProc2Mat\ImageProc2Demo

clear,clc,close all,home


load lenna256.mat
% loads the image into the matrix x
Bits=8;
p=2^Bits-1;
x=p.*(x./(max(max(x))));
grayimage(x);
pause

while 1
Nbit=input('Number of quantiser bits ( 0 to break)= ');
if Nbit==0, break, end
gq=fix(x./(2^(Bits-Nbit)));
close

subplot(1,2,1),grayimage(x);
title('Original image');
subplot(1,2,2),grayimage(gq);
title(['Quantised image  '])
pause
end


