I=imread (fn);J=I;%计算灰度图象的直方图数据L=256; %灰度级Ps = zeros(L,1); %统计直方图结果数据nk=zeros(L,1);[row,col]=size(I);n=row*col; %总像素个数for i = 1:rowfor j = 1:col