标签:end 均衡化 imshow class img code max col mat
1 cl; 2 img=imread(‘mask.jpg‘); 3 imshow(img); 4 [x,y]=size(img); 5 img_man=zeros(x,y); 6 img_com=zeros(x,y); 7 8 %% 直方图均衡化算法 9 Max=max(max(img)); 10 Min=min(min(img)); 11 Hist=zeros(1,256); 12 for i=1:x 13 for j=1:y 14 Hist(img(i,j)+1)=Hist(img(i,j)+1)+1; 15 end 16 end 17 figure,plot(Hist); 18 19 p=zeros(1,256); 20 for i=1:256 21 p(i)=Hist(i)/(x*y); 22 end 23 figure,plot(p); 24 25 c=zeros(1,256); 26 for i=1:256 27 c(i)=sum(p(1:i)); 28 end 29 figure,plot(c); 30 31 for i=1:x 32 for j=1:y 33 img_man(i,j)=c(img(i,j)+1)*(Max-Min)+Min; 34 end 35 end 36 37 figure,imshow(uint8(img_man)) 38 39 Hist2=zeros(1,256); 40 for i=1:x 41 for j=1:y 42 Hist2(img_man(i,j)+1)=Hist2(img_man(i,j)+1)+1; 43 end 44 end 45 figure,plot(Hist2); 46 47 %% matlab直方图均衡化函数 48 img_com=histeq(img); 49 figure,imshow(img_com) 50 51 Hist3=zeros(1,256); 52 for i=1:x 53 for j=1:y 54 Hist3(img_com(i,j)+1)=Hist3(img_com(i,j)+1)+1; 55 end 56 end 57 figure,plot(Hist3);
标签:end 均衡化 imshow class img code max col mat
原文地址:https://www.cnblogs.com/ybqjymy/p/13645861.html