zoukankan      html  css  js  c++  java
  • OpenCv 018---图像直方图均衡化

    1 前备知识

      图像直方图均衡化可以用于图像增强,对图像进行直方图均衡化处理,可提升后续对象检测的准确率,医学影像图像、卫星遥感图像、机器视觉产品图像均可通过直方图均衡化对图像质量进行提升,对比度增强。

    2 所用到的主要OpenCv API

    CV_EXPORTS_W void equalizeHist( InputArray src, OutputArray dst );

    /** @brief Equalizes the histogram of a grayscale image.

    The function equalizes the histogram of the input image using the following algorithm:

    - Calculate the histogram f$Hf$ for src .
    - Normalize the histogram so that the sum of histogram bins is 255.
    - Compute the integral of the histogram:
    f[H'_i = sum _{0 le j < i} H(j)f]
    - Transform the image using f$H'f$ as a look-up table: f$ exttt{dst}(x,y) = H'( exttt{src}(x,y))f$

    The algorithm normalizes the brightness and increases the contrast of the image.

    @param src Source 8-bit single channel image.
    @param dst Destination image of the same size and type as src .
    */

    3 程序代码

    #include <opencv2opencv.hpp>
    #include <iostream>
    
    using namespace std;
    using namespace cv;
    
    int main(int argc, char** argv)
    {
        Mat src = imread("G:\CVworkstudy\program_wwx\Research society140\ZhaiZhigang140\colormap.png");
        if (src.empty())
        {
            printf("Could not load image...
    ");
            return -1;
        }
        namedWindow("input", WINDOW_AUTOSIZE);
        Mat gray, dst;
        cvtColor(src, gray, COLOR_BGR2GRAY);
        imshow("input", gray);
        equalizeHist(gray, dst);
        imshow("eq", dst);
    
        waitKey(0);
        return 0;
    }

    4 运行结果

    5 扩展及注意事项

    null

    One day,I will say "I did it"
  • 相关阅读:
    第十六章 课程总复习
    第四章 数据类型及数据库基本操作
    第二章.图形化管理工具
    第十三章 指导学习:人机猜拳
    洛谷 P4396 (离散化+莫队+树状数组)
    洛谷 P1351 (枚举)
    洛谷P5322 (BJOI 2019) DP
    P3376 网络最大流模板(Dinic + dfs多路增广优化 + 炸点优化 + 当前弧优化)
    洛谷 P2176(最短路)
    HDU 6556 (2018CCPC吉林 B题)
  • 原文地址:https://www.cnblogs.com/Vince-Wu/p/11402906.html
Copyright © 2011-2022 走看看