 <ol> <li>Create the histogram for the image.</li> <li>Calculate the cumulative distribution function histogram.</li> <li>Calculate the new values through the general histogram equalization formula.</li> <li><p>Assign new values for each gray value in the image.</p> <pre><code>clc close all clear all %% HISTOGRAM EQULAIZER %% I1= imread ('C:\Users\sepideh\Pictures\dip\PC040311.jpg'); zz=rgb2gray(I1); figure,subplot(1,2,1),imshow(zz), title('original image') subplot(1,2,2),imhist(zz),title('original image histogram') %% Calculating the CDF hst=imhist(zz); j=1; cdff(1,1)=hst(1,1); for i=2:256 cdff(i)=hst(i)+cdff(i-j); end cdff1=cdff'; cdf_min=min(cdff); [row col]=size(zz); mn=row*col; figure, plot(cdff), title('CDF of Image') %% calcuting new intensity for indx=1:length(cdff) h(indx)=round((cdff(indx)-cdf_min)/(mn-cdf_min)*255); end h1=h'; figure,plot(h1), title('New value for General Histogram') %% EQULIZED IMAGE HIm=uint8(zeros(size(zz,1),size(zz,2))); for i=1:row; for j=1:col; HIm(i,j) = h((zz(i,j)+1)); end end figure,subplot(1,2,1),imshow(HIm), title('Equlized Image') subplot(1,2,2),imhist(HIm) ,title('Equlized image histogram') </code></pre></li> </ol>