Skip to content

Instantly share code, notes, and snippets.

@mitjap
Created October 18, 2013 17:38
Show Gist options
  • Save mitjap/7045102 to your computer and use it in GitHub Desktop.
Save mitjap/7045102 to your computer and use it in GitHub Desktop.
equihist
function img_eq = equihist(img)
% compute hist with 256 bins
h = myhist(img, 256);
% cum hist
%for i = 2 : size(h(:))
% h(i) = h(i) + h(i-1);
%end
h = cumsum(h);
% normalize hist
h *= 256 / max(h);
% use hist as a lookup
h = uint8(h);
img_eq = img;
%for row = 1 : size(img, 1)
% for col = 1 : size(img, 2)
% img_eq(row, col) = h(img(row, col));
% end
%end
img_eq = h(img);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment