zoukankan      html  css  js  c++  java
  • OpenCV2:大学应用篇 图像增强技术

    一.简介

    图像增强操作的作用是提高图像细节,包括 图像降噪 图像平滑 图像边缘增强

    图像校正是修复一副受损的图像

    二.基于直方图均衡化的图像增强

    直方图均衡化是通过调整图像灰阶分布,使得在0~255灰阶上的分布更加均衡,提高了图像的对比度

    #include <opencv2/highgui/highgui.hpp>
    #include <opencv2/imgproc/imgproc.hpp>
    #include <iostream>
    
    using namespace cv;
    
    int main(int argc, char* argv[])
    {
        cv::Mat image = cv::imread("a.jpg", 1);
        if (image.empty())
        {
            std::cout << "打开失败" << std::endl;
            return -1;
        }
    
        cv::imshow("源图像", image);
        cv::Mat imageRGB[3];
        split(image, imageRGB);
    
        for (int i = 0; i < 3; i++)
        {
            cv::equalizeHist(imageRGB[i], imageRGB[i]);
        }
    
        cv::merge(imageRGB, 3, image);
        cv::imshow("直方图均衡化增强效果", image);
        cv::waitKey(0);
        return 0;
    }

    三.基于拉普拉斯算子的图像增强

     使用中心为5的8领域拉普拉斯算子与图像卷积可以达到锐化和增强图像的目的

    #include <opencv2/highgui/highgui.hpp>
    #include <opencv2/imgproc/imgproc.hpp>
    #include <iostream>
    
    using namespace cv;
    
    int main(int argc, char* argv[])
    {
        cv::Mat image = cv::imread("a.jpg", 1);
        if (image.empty())
        {
            std::cout << "打开图片失败" << std::endl;
            return -1;
        }
    
        cv::imshow("源图像", image);
        cv::Mat imageEnhance;
        cv::Mat kernel = (Mat_<float>(3, 3) << 0, -1, 0, 0, 5, 0, 0, -1, 0);
        cv::filter2D(image, imageEnhance, CV_8UC3, kernel);
        cv::imshow("拉普拉斯算子图像增强效果", imageEnhance);
    
        cv::waitKey(0);
        return 0;
    }

    四.基于对数Log变换的图像增强

    五.基于伽玛(Gamma)变换的图像增强

  • 相关阅读:
    POJ 3268 Silver Cow Party (Dijkstra)
    怒学三算法 POJ 2387 Til the Cows Come Home (Bellman_Ford || Dijkstra || SPFA)
    CF Amr and Music (贪心)
    CF Amr and Pins (数学)
    POJ 3253 Fence Repair (贪心)
    POJ 3069 Saruman's Army(贪心)
    POJ 3617 Best Cow Line (贪心)
    CF Anya and Ghosts (贪心)
    CF Fox And Names (拓扑排序)
    mysql8.0的新特性
  • 原文地址:https://www.cnblogs.com/k5bg/p/11230878.html
Copyright © 2011-2022 走看看