MATLAB: HISTEQ default not consistent with syntax

histeq

If I have an 8-bit image IM (e.g. cameraman.tif), why does histeq(IM) produce a different result than histeq(IM,ones(1,256))??
Shouldn't they be identical? The description says hgram defaults to ones(1,n)*prod(size(A))/n. Since cameraman is 256×256 and n=2^8, shouldn't it scale normally?

Best Answer

IM = imread('cameraman.tif');
I = histeq(IM);
I2 = histeq(IM,ones(1,64)*(numel(IM)/64));
isequal(I,I2)
ans =
1
Related Question