final_img=imread('fig3.jpg'); input_img=imread('fig3.jpg'); [m n]=size(input_img); mn=m*n; pdf=zeros(1,256); cdf=zeros(1,256); tmp=zeros(1,256); final=zeros(m,n); %a=0; %b=0; for k=1:m for l=1:n for r=0:255 if(input_img(k,l)==r) pdf(1,r+1)=pdf(1,r+1)+1; end end end end sum=0; for i=1:256 sum=sum+pdf(1,i); cdf(1,i)=sum; end for i=1:256 tmp(1,i)=floor((cdf(1,i)/(mn))*255); end for i=1:m for j=1:n for k=0:255 if input_img(i,j)==k break; end end final_img(i,j)=tmp(1,k+1); end end subplot(2,2,1); imshow(input_img); title('Input image'); subplot(2,2,2); plot(pdf); title('PDF'); subplot(2,2,3); imshow(final_img); title('Equalized image'); subplot(2,2,4); plot(cdf); title('CDF');
Saturday, September 8, 2012
[MATLAB] Histogram Equalization program
Subscribe to:
Post Comments (Atom)