Transcript

1function [a] = hist_equal( name )a = imread(name);hist = histo(name);cdf = zeros(1,256);mincdf = 0;for i=1:256if(i==1)cdf(1) = hist(1);else cdf(i) = cdf(i-1) + hist(i);endmincdf = min(mincdf,cdf(i));endcdf_sc = zeros(1,256);for i = 1:256cdf_sc(i) = round(((cdf(i) - mincdf)*(255))/(262144 - mincdf));endfor i = 1:512for j = 1:512a(i,j) = cdf_sc(a(i,j) + 1);endendhistogram = zeros(1,256);for i = 1:512for j = 1:512val = a(i,j) + 1;histogram(val) = histogram(val) + 1;endendx = 0:255;imshow(a);plot(x,histogram);endPublished with MATLAB 7.14


Top Related