如何用matlab做图片的灰度直方图

如题所述

第1个回答  2013-12-14
或者在 matlab下边输入 help imhistedit histeq%%%灰度图象的直方图数据%%%clcclearfn='rice.tif';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:colnum = double(I(i,j))+1; %获取像素点灰度级nk(num) = nk(num)+1; %统计nkendend%计算直方图概率估计for i=1:LPs(i)=nk(i)/n;endfigure;subplot(3,1,1);imshow(J),title('原图');subplot(3,1,2),plot(nk),title('直方图(nk)');subplot(3,1,3),plot(Ps),title('直方图(Ps)');%figure(4),imhist(hist);%p=imhist(hist); %生成直方图函数,返回灰度图象直方图数据本回答被提问者采纳
相似回答