直方图均衡化
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);
结果如下:
第一列显示的是未处理的图像;第二列为该图像的直方图;第三列为直方图均衡化后的图像;第四列为处理后的图像直方图。
从图像中,可明显看出,均衡化后的图像在对比度上得到了增强,其原因是均衡化扩大了图像的灰度级范围。
离散情况下,一幅图像中的灰度级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);
结果如下:
第一列显示的是未处理的图像;第二列为该图像的直方图;第三列为直方图均衡化后的图像;第四列为处理后的图像直方图。
从图像中,可明显看出,均衡化后的图像在对比度上得到了增强,其原因是均衡化扩大了图像的灰度级范围。
相关文章推荐
- POJ 2251:Dungeon Master
- POI-----POI操作Excel-3、单元格
- MFC CtreeCtrl 节点的遍历
- DELPHI中自定义消息的发送和接收
- measure_circuit_width_lines_gauss.hdev检测pcb线宽 相关例程学习
- MySQL之查询性能优化二
- POJ 2251:Dungeon Master
- 常用博客地址搬家
- 手动编译安装LAMP架构,并且实现nagios图形化监控(八)
- list + radio 实现自定义单选
- PAT (Advanced Level) 1093. Count PAT's (25) 一维动态规划
- TCP/IP学习(四)TCP缓冲区大小及限制
- css3画圆
- HBase - Rowkey 设计 | 那伊抹微笑
- web.xml中load-on-startup的作用
- 椭圆拟合算法总结
- 项目管理经验总结
- Transfrom在64bit服务下面无法运行
- 第一次用IIS发布网站时遇到的两个问题
- requireJs详解(二)