I have a series of images with decreasing brightness that I would like to try to correct with histogram equalization. I applied histeq
to some test data to learn how the function works
% Image that I would like to apply histogram equalization to
C = gallery('wilk',21);
figure, imagesc(C)
E = histeq(C);
figure, imagesc(E);
However, when I look at the output of histeq
, I get a result that only has two unique values: 0.873
and 1.000
. How come the output doesn't span the whole range of the input? I would expect there to be more than two unique values in the output.
According to the documentation for histeq
, if the input is of type double
or single
it is expected to be in the range: [0, 1]
.
Intensity values in the appropriate range: [0, 1] for images of class double, [0, 255] for images of class uint8, and [0, 65535] for images of class uint16.
Your data is not normalized and is of type double
,
whos C
% Name Size Bytes Class Attributes
%
% C 21x21 3528 double
[min(C(:)), max(C(:))]
% 0 10
You will need to normalized it first. You can use mat2gray
to do this:
E = histeq(mat2gray(C));