clear;clc;
I=imread('Lena.bmp');
%将 256 级的图像转换成128级,64级,32级灰度图像
%量化成128级
A=(0.5)*I;A1=floor(A);
%量化成64级
B=(0.25)*I;B1=floor(B);
%量化成32级
C=(0.125)*I;C1=floor(C);
figure
imshow(I);
figure
subplot(1,3,1),imshow(A1,[0,127]);title('128级灰度图像');
subplot(1,3,2),imshow(B1,[0,63]);title('64级灰度图像');
subplot(1,3,3),imshow(C1,[0,31]);title('32级灰度图像');