广告合作
  • 今日头条

    今日头条

  • 百度一下

    百度一下,你就知道

  • 新浪网

    新浪网 - 提供新闻线索,重大新闻爆料

  • 搜狐

    搜狐

  • 豆瓣

    豆瓣

  • 百度贴吧

    百度贴吧——全球领先的中文社区

  • 首页 尚未审核订阅工具 订阅

    视觉图像:对比度受限直方图均衡化CLAHE

    来源:网络收集  点击:  时间:2024-09-02
    【导读】:
    绪:直方图均衡简单、高效;但是,图像中不同的区域灰度分布相差甚远,对它们使用同一种变换常常产生不理想的效果;实际应用中,常常需要增强图像的某些局部区域的细节。为了解决这类问题,Pizer等提出了局部直方图均衡化的方法(AHE);AHE方法仅仅考虑了局部区域的像素,忽略了图像其他区域的像素,且对于图像中相似区域具有过度放大噪声的缺点;K. Zuiderveld等人提出了对比度受限CLAHE的图像增强方法;通过限制局部直方图的高度来限制局部对比度的增强幅度,从而限制噪声的放大及局部对比度的过增强;也可以被用来对图像去雾操作;CLAHE和AHE的区别在于前者对区域对比度进行了限制,且采用插值来加快计算;工具/原料moreOpenCV 2.4.10方法/步骤1/5分步阅读

    1、CLAHE算法原理:

    CLAHE与AHE不同的地方是对比度限幅,为了克服AHE的过度放大噪声的问题;

    ①设自适应直方图均衡化方法的滑动窗口大小为M*M,则局部映射函数为:

    为滑动窗口局部直方图的累积分布函数(cumulative distribution function);

    ②的导数为直方图,从而局部映射函数的斜率S为:

    故,限制直方图高度就等效于限制局部映射函数的斜率,进而限制对比度强度;

    ③设限定最大斜率为Smax,则允许的直方图高度最大为:

    ④对高度大于Hmax的直方图应截去多余的部分;

    实际处理中,设截取阈值T(而非Hmax)对直方图进行截断,将截去的部分均匀的分布在整个灰阶范围上,以保证总的直方图面积不变,从而使整个直方图上升高度L,则有:

    ⑤最后改进的直方图为:

    综上所述,改变最大的映射函数斜率Smax及相应的最大直方图高度Hmax,可获得不同增强效果的图像;

    CLAHE通过限制局部直方图的高度来限制局部对比度的增强幅度,从而限制噪声的放大和局部对比度的过增强。

    2/5

    插值加速方法:

    AHE方法,不管是否带有对比度限制,都需要对图像中的每个像素计算其领域及变换函数,算法耗时严重;

    对其进行插值加速,使算法效率有极大提升,且质量没有下降;

    ①将图像均匀分成等份矩阵大小,常见8行8列64块;

    ②计算每个块的直方图,CDF,变换函数;

    对于块的中心像素(黑色小方块)是完全符合定义的;

    ③对其他的像素通过其邻近的四个黑色小方块的变换函数插值来获取;

    位于中间的像素(蓝色阴影)采用双线性插值;

    位于边缘的部分(绿色阴影)采用线性插值;

    位于角点处的部分(红色阴影)采用块所在的变换函数;

    3/5

    OpenCV中,CLAHE函数实现:

    #includeopencv2\core\core.hpp

    #include opencv2\opencv.hpp

    #includevector

    using namespace cv;

    using namespace std;

    int main(int argc, char** argv)

    {

    // 读取RBG图片,转成Lab模式

    Mat bgr_image = imread(src.jpg);

    if (!bgr_image.rows){

    cout imread failed! endl;

    return 0;

    }

    Mat lab_image;

    cvtColor(bgr_image, lab_image, CV_BGR2Lab);

    // 提取L通道

    vectorMat lab_planes(3);

    split(lab_image, lab_planes);

    // CLAHE 算法

    PtrCLAHE clahe = createCLAHE();

    clahe-setClipLimit(4);

    Mat dst;

    clahe-apply(lab_planes, dst);

    dst.copyTo(lab_planes);

    merge(lab_planes, lab_image);

    //恢复RGB图像

    Mat image_clahe;

    cvtColor(lab_image, image_clahe, CV_Lab2BGR);

    //打印结果

    imshow(原始图片, bgr_image);

    imshow(CLAHE处理, image_clahe);

    waitKey();

    return 0;

    }

    4/5

    CLAHE源码解析:

    ContrastLimitAHE .h:

    #ifndef _CONTRAST_LIMIT_AHE_H_

    #define _CONTRAST_LIMIT_AHE_H_

    #include stdafx.h

    #include iostream

    using namespace std;

    class ContrastLimitAHE

    {

    public:

    ContrastLimitAHE();

    ~ContrastLimitAHE();

    int m_nGridX; /* CLAHE 宽网格的个数 */

    int m_nGridY; /* CLAHE 高网格的个数 */

    unsigned char m_aLUT; /* CLAHE lookup table used for scaling of input image 输入图像缩放的查找表*/

    int Initial(int nMaxPixel, int nMinPixel, int uiNrBins, int nX, int nY, int nWidth, int nHeight,float fCliplimit);

    int m_nWidth; /* CLAHE 宽 */

    int m_nHeight; /* CLAHE 高 */

    int m_nCliplimit;

    int m_nHistBins;

    int m_nGridSize_X;

    int m_nGridSize_Y;

    int *m_pMapArray;

    int m_nGridSize; /* Actual size of contextual regions实际周边区域大小 */

    int ProcessCLAHE(unsigned char* pImage);

    void MakeHistogram(unsigned char* pImage,int* pulHistogram);

    void ClipHistogram(int* pulHistogram);

    void MapHistogram(int* pulHistogram);

    void Interpolate (unsigned char * pImage);

    int m_nMaxPixel;

    int m_nMinPixel;

    void ShiftInterpolate(unsigned char* pImage, int nSizeX, int nSizeY, int* pulMapLU, int* pulMapRU, int *pulMapLB, int *pulMapRB);

    int LineInterpolate(unsigned char* pImage, int nSizeX, int nSizeY, int* pLU, int* pRU, int* pLB, int* pRB);

    };

    #endif

    5/5

    参考资料:

    D. J. Ketcham, R. W. Lowe J. W. Weber: Image enhancement techniques for cockpit displays. Tech. rep., Hughes Aircraft. 1974.

    R. A. Hummel: Image Enhancement by Histogram Transformation. Computer Graphics and Image Processing 6 (1977) 184195.

    S. M. Pizer, E. P. Amburn, J. D. Austin, et al.: Adaptive Histogram Equalization and Its Variations. Computer Vision, Graphics, and Image Processing 39 (1987) 355-368.

    K. Zuiderveld: Contrast Limited Adaptive Histogram Equalization. In: P. Heckbert: Graphics Gems IV, Academic Press 1994, ISBN 0-12-336155-9

    T. Sund A. Møystad: Sliding window adaptive histogram equalization of intra-oral radiographs: effect on diagnostic quality. Dentomaxillofac Radiol. 2006 May;35(3):133-8.

    注意事项

    灰度映射表

    双线性插值加速

    图像算法图像增强直方图均衡化CLAHECLAHE程序
    本文关键词:

    版权声明:

    1、本文系转载,版权归原作者所有,旨在传递信息,不代表看本站的观点和立场。

    2、本站仅提供信息发布平台,不承担相关法律责任。

    3、若侵犯您的版权或隐私,请联系本站管理员删除。

    4、文章链接:http://www.1haoku.cn/art_1188225.html

    相关资讯

    ©2019-2020 http://www.1haoku.cn/ 国ICP备20009186号05-06 12:12:01  耗时:0.024
    0.0244s