function J = hist_eq(I)
% My implementation of histogram equalization
% I: Input Image
% J: Output Image
% Dr. W.D.Pan, UAH

L = 256;
K = (L-1)/ numel(I);
[counter, bin] = imhist(I);

transf = bin;
sum = 0;
for i = 1: length(bin)
    sum = sum + counter(i);
    transf(i) = uint8(round(K * sum));
end

J = uint8(transf(I+1));

end

