for i=1:26 f=strcat(D:bishe,num2str(i); image=strcat(f,.jpg); PS=imread(image); PS=imresize(PS,300,300,bilinear);%归一化大小 PS=rgb2gray(PS); m,n=size(PS); %测量图像尺寸参数 GP=zeros(1,256); %预创建存放灰度出现概率的向量 for k=0:255 GP(k+1)=length(find(PS=k)/(m*n); %计算每级灰度出现的概率,将其存入GP中相应位置 end%直方图均衡化 S1=zeros(1,256); for i=1:256 for j=1:i S1(i)=GP(j)+S1(i); %计算Sk end end