function h = entropy(x)
%
%  Entropy of an image
%

counts = imhist(x);
counts = counts / sum(counts);
i = find(counts);
h = -sum(counts(i).*log2(counts(i)));
