图像处理的有用资料
xlabel('原图像灰度级') ylabel('均衡化后灰度级')
%四,图像均衡化 PA=PS;
for i=0:255
PA(find(PS==i))=S2(i+1); %将各个像素归一化后的灰度值赋给这个像素 end
figure,imshow(PA) %显示均衡化后的图像 figure NO 6
title('均衡化后图像')
imwrite(PA,'PicEqual.bmp');
另一段Matlab的代码,来自 直方图均衡化--图像增强 I=imread('LENA256.bmp');
imshow(I); figure; imhist(I);
[m,n]=size(I); hf = zeros(1,256); pa = zeros(1,256); I=double(I);
for i = 1:m for j = 1:n
hf(I(i,j)+1)=hf(I(i,j)+1)+1;%统计各灰度像素个数 end end
bmap=zeros(1,256);
for i=1:256 temp=0; for j=1:i
temp=temp+hf(j); end
bmap(i)=floor(temp*255/(m*n)); end
y=zeros(m,n);
for i=1:m
for j=1:n