Tuesday, 3 May 2016

My MATLAB code for histogram equalization

Check this code. I couldn't make it without a for loop. Let me know, if there is a smarter way for it.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
%% My MATLAB code for finding new equilized histogram
r = [23 12 354 580 215 35 48 8]
pr = r/sum(r)
t= cumsum(pr)*(length(r)-1)
T = round(t)
NewHist = zeros(size(T));
for i=unique(T)
    NewHist(i+1) =  sum(r(T==i));
end
stem(NewHist)