直方图均衡产生意想不到的结果
Histogram Equalization yielding unexpected results
我有一系列亮度降低的图像,我想尝试使用直方图均衡进行校正。我将 histeq
应用于一些测试数据以了解该函数的工作原理
% Image that I would like to apply histogram equalization to
C = gallery('wilk',21);
figure, imagesc(C)
E = histeq(C);
figure, imagesc(E);
但是,当我查看 histeq
的输出时,我得到的结果只有两个唯一值:0.873
和 1.000
。为什么输出没有跨越输入的整个范围?我希望输出中有两个以上的唯一值。
根据 histeq
的文档,如果输入是 double
或 single
类型,则它应在范围内:[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.
您的数据未规范化,类型为 double
、
whos C
% Name Size Bytes Class Attributes
%
% C 21x21 3528 double
[min(C(:)), max(C(:))]
% 0 10
您需要先对其进行标准化。您可以使用 mat2gray
来执行此操作:
E = histeq(mat2gray(C));
我有一系列亮度降低的图像,我想尝试使用直方图均衡进行校正。我将 histeq
应用于一些测试数据以了解该函数的工作原理
% Image that I would like to apply histogram equalization to
C = gallery('wilk',21);
figure, imagesc(C)
E = histeq(C);
figure, imagesc(E);
但是,当我查看 histeq
的输出时,我得到的结果只有两个唯一值:0.873
和 1.000
。为什么输出没有跨越输入的整个范围?我希望输出中有两个以上的唯一值。
根据 histeq
的文档,如果输入是 double
或 single
类型,则它应在范围内:[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.
您的数据未规范化,类型为 double
、
whos C
% Name Size Bytes Class Attributes
%
% C 21x21 3528 double
[min(C(:)), max(C(:))]
% 0 10
您需要先对其进行标准化。您可以使用 mat2gray
来执行此操作:
E = histeq(mat2gray(C));