• opencv3 图片模糊操作-均值滤波 高斯滤波 中值滤波 双边滤波


    #include <iostream>
    #include <opencv2/opencv.hpp>

    using namespace std;
    using namespace cv;

    //均值滤波模糊处理
    int demo_blur()
    {
      char win1[] = "window1";
      char win2[] = "window2";
      Mat img1, img2;

      img1 = imread("D://images//4.jpg");
      if (img1.empty())
      {
        cout <<"could not found img..." << endl;
        return 0;
      }
      imshow(win1,img1);
      blur(img1,img2,Size(9,9),Point(-1,-1));
      imshow(win2, img2);
      return 0;
    }

    //高斯滤波
    int demo_gaussian_blur()
    {
      char win1[] = "window1";
      char win2[] = "window2";
      Mat img1, img2;

      img1 = imread("D://images//timg1.jpg");
      if (img1.empty())
      {
        cout << "could not found img..." << endl;
        return 0;
      }
      imshow(win1, img1);
      //blur(img1, img2, Size(9, 9), Point(-1, -1));
      GaussianBlur(img1, img2, Size(9, 9), 11, 11, 4);
      imshow(win2, img2);
      return 0;
    }

    //中值滤波
    int demo_median_blur()
    {
      char win1[] = "window1";
      char win2[] = "window2";
      Mat img1, img2;

      img1 = imread("D://images//2018092701.jpg");
      if (img1.empty())
      {
        cout << "could not found img..." << endl;
        return 0;
      }
      imshow(win1, img1);
      //blur(img1, img2, Size(9, 9), Point(-1, -1));
      //GaussianBlur(img1, img2, Size(9, 9), 11, 11, 4);
      medianBlur(img1, img2, 5);
      imshow(win2, img2);
      return 0;
    }

    //双边滤波
    int demo_bilateral_filter()
    {
      char win1[] = "window1";
      char win2[] = "window2";
      Mat img1, img2;

      img1 = imread("D://images//timg1.jpg");
      if (img1.empty())
      {
        cout << "could not found img..." << endl;
        return 0;
      }
      imshow(win1, img1);
      //blur(img1, img2, Size(9, 9), Point(-1, -1));
      //GaussianBlur(img1, img2, Size(9, 9), 11, 11, 4);
      //medianBlur(img1, img2, 5);
      bilateralFilter(img1, img2, 15, 100, 3, 4);
      imshow(win2, img2);
      return 0;
    }


    int main()
    {
      //demo_blur();
      //demo_gaussian_blur();
      //demo_median_blur();
      demo_bilateral_filter();

      waitKey(0);
      return 0;
    }

     

  • 相关阅读:
    【面向对象-天龙八部】
    【面向对象-作业】
    【OOP】面向对象的程序开发
    nmcli命令详解(创建热点,连接wifi,管理连接等)
    构造函数&&继承8.1
    Set集合之TreeSet类
    Set集合之HashSet类
    HDFS上传数据的流程
    zookeeper的安装与配置
    hive介绍、安装配置、表操作基础知识适合小白学习
  • 原文地址:https://www.cnblogs.com/herd/p/9733374.html
Copyright © 2020-2023  润新知