1. 程式人生 > >方框濾波、均值濾波、高斯濾波及濾波函式

方框濾波、均值濾波、高斯濾波及濾波函式

方框濾波、均值濾波、高斯濾波及濾波函式相關函式如下:

void cv::boxFilter( InputArray _src,OutputArray _dst, int ddepth,
                Size ksize, Point anchor,
                bool normalize, int borderType);
void cv::blur(InputArray src, OutputArray dst,
          Size ksize, Point anchor, int borderType );
void cv::GaussianBlur( InputArray _src,OutputArray _dst, Size ksize,
                   double sigma1, doublesigma2,
                   int borderType );

濾波的簡單使用:

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

using namespace cv;

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
//    Widget w;
//    w.show();

    namedWindow("【原圖】" );
    namedWindow("BOX【效果圖】");
    namedWindow("Blur【效果圖】");
    namedWindow("GaussianBlur【效果圖】");

    Mat srcImg = imread("../imgs/a.jpeg");
    imshow("【原圖】" , srcImg);

    Mat Boxout;
    cv::boxFilter(srcImg, Boxout, -1, cv::Size(7,7));
    imshow("BOX【效果圖】", Boxout);

    Mat Blurout;
    cv::blur(srcImg, Blurout, Size(7,7));
    imshow("Blur【效果圖】", Boxout);

    Mat GaussianBlurout;
    cv::GaussianBlur(srcImg, GaussianBlurout, Size(7,7), 0,0);
    imshow("GaussianBlur【效果圖】", GaussianBlurout);

    return a.exec();
}