OpenCV学习笔记-\doc\tutorials\imgproc\gausian_median_blur_bilateral_filter
文档中没有修改作者的代码,作者程序的意思是要逐个显示四个滤波器的处理结果,我将代码修改了一下,一并显示结果,其中MAX_KERNEL_LENGTH取为31,这次不用lena了,用林采缇同学来提神。显示结果如下:
代码如下:
#include "opencv2/imgproc/imgproc.hpp" #include "opencv2/highgui/highgui.hpp" using namespace std; using namespace cv; /// Global Variables int MAX_KERNEL_LENGTH = 31; Mat src; Mat dst1,dst2,dst3,dst4; int main( int argc, char** argv ) { // Create Windows namedWindow("Source Image"); namedWindow("Homogeneous Blur"); namedWindow("Gaussian Blur"); namedWindow("Median Blur"); namedWindow("Bilateral Blur"); // Load the source image src = imread( "azhai.jpg", 1 ); // Show Original Image imshow("Source Image",src); // Copies for output dst1 = src.clone(); dst2 = src.clone(); dst3 = src.clone(); dst4 = src.clone(); // Applying Homogeneous blur blur( src, dst1, Size(MAX_KERNEL_LENGTH,MAX_KERNEL_LENGTH), Point(-1,-1) ); imshow("Homogeneous Blur",dst1); // Applying Gaussian blur GaussianBlur( src, dst2, Size(MAX_KERNEL_LENGTH,MAX_KERNEL_LENGTH), 0, 0 ); imshow("Gaussian Blur",dst2); // Applying Median blur medianBlur ( src, dst3, MAX_KERNEL_LENGTH); imshow("Median Blur",dst3); // Applying Bilateral Filter bilateralFilter ( src, dst4, MAX_KERNEL_LENGTH, MAX_KERNEL_LENGTH*2, MAX_KERNEL_LENGTH/2 ); imshow("Bilateral Blur",dst4); waitKey(0); return 0; }