码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-09-30 21:52:13      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:dia   图片模糊   处理   bubuko   not found   com   main   技术分享   stream   

#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;
}

 技术分享图片

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

标签:dia   图片模糊   处理   bubuko   not found   com   main   技术分享   stream   

原文地址:https://www.cnblogs.com/herd/p/9733374.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!