1. 程式人生 > >OpenCV(模糊影象一)

OpenCV(模糊影象一)

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

using namespace cv;
using namespace std;

int main(int argc, char** argv) {
	Mat src, dst;
	src = imread("F:\\test.jpg");
	if (!src.data) {
		cout << "could not load image..." << endl;
		return -1;
	}
	char input_title[] = "input image";
	char output_title[] = "blur image";
	namedWindow(input_title, CV_WINDOW_AUTOSIZE);
	namedWindow(output_title, CV_WINDOW_AUTOSIZE);
	imshow(input_title, src);

	//均值模糊
	blur(src, dst, Size(11, 11), Point(-1, -1));		
	//Size(1, 15)指只進行y方向的模糊,Size(7, 7)均值模糊,Size(x, y)其中x, y都是正數且是奇數
	imshow(output_title, dst);

	//高斯模糊
	Mat gblur;
	GaussianBlur(src, gblur, Size(11, 11), 11, 11);
	imshow("gaussian blur", gblur);

	waitKey(0);
	return 0;
}

執行結果