filter2D滤波处理函数-----学习记录(2)

#include "stdafx.h"
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"  
#include "opencv2/highgui/highgui.hpp"
using namespace cv;

int main(int argc, char* argv[])
{
	Mat I, K,kern;
	int kern_size;
	I = imread(argv[1]);
	namedWindow("Input", WINDOW_AUTOSIZE);
	namedWindow("Output", WINDOW_AUTOSIZE);
	imshow("Input", I);
	int ind = 0;
	while(true){
		char c = cvWaitKey(500);
		if(c == 27) break;//按Ecs键跳出程序
		kern_size = 3 + 2*(ind%5); //处理的掩膜大小为3,5,7,9,11
	    kern = Mat::ones(kern_size,kern_size,CV_32F)/(float)(kern_size*kern_size);
		filter2D(I, K, I.depth(), kern );
		imshow("Output",K);
	ind++;	 
	}
	/*Mat kern = (Mat_<char>(3,3)<< 0, -1, 0,
				        -1, 5, -1,
					0,  -1, 0);*/
	
	return 0;
}

你可能感兴趣的:(filter2D滤波处理函数-----学习记录(2))