您的位置:首页 > 其它

直方图均衡化

2015-07-31 15:27 197 查看
在数字图像处理中,直方图均衡化的作用是一种自适应增强对比度。它根据提供的图像,自动提取信息进行处理,不需要额外参数的配合,工作原理简单如下:

离散情况下,一幅图像中的灰度级r出现的概率近似为:



其中,M,N分别代表图像的像素长、宽,MN为图像的像素总数,nk是灰度级为k的像素个数,L是图像中可能的灰度级数量(8位图像是256)。

对离散图像进行均衡化的变换函数为:



在连续值中,均衡化变换可使每一个值出现的概率都相同,为1/(L-1)。

在matlab中,对数字图像处理(第三版)中的实例进行了实现。

程序如下:

%%

%直方图均衡化

%作者:褚凯

%日期:2015.07.31

%%

tempImg = imread('Fig0316(4)(bottom_left).tif');

figure;

subplot(4,4,1);

imshow(tempImg);

subplot(4,4,2);

imhist(tempImg);

J= histeq(tempImg);

subplot(4,4,3);

imshow(J);

subplot(4,4,4);

imhist(J);

tempImg = imread('Fig0316(1)(top_left).tif');

subplot(4,4,5);

imshow(tempImg);

subplot(4,4,6);

imhist(tempImg);

J= histeq(tempImg);

subplot(4,4,7);

imshow(J);

subplot(4,4,8);

imhist(J);

tempImg = imread('Fig0316(2)(2nd_from_top).tif');

subplot(4,4,9);

imshow(tempImg);

subplot(4,4,10);

imhist(tempImg);

J= histeq(tempImg);

subplot(4,4,11);

imshow(J);

subplot(4,4,12);

imhist(J);

tempImg = imread('Fig0316(3)(third_from_top).tif');

subplot(4,4,13);

imshow(tempImg);

subplot(4,4,14);

imhist(tempImg);

J= histeq(tempImg);

subplot(4,4,15);

imshow(J);

subplot(4,4,16);

imhist(J);

结果如下:



第一列显示的是未处理的图像;第二列为该图像的直方图;第三列为直方图均衡化后的图像;第四列为处理后的图像直方图。

从图像中,可明显看出,均衡化后的图像在对比度上得到了增强,其原因是均衡化扩大了图像的灰度级范围。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: