|
The function smoothes an image using the kernel:
高斯滤波,对去除正态分布的噪声很有用
|
用自己的核函数进行滤波
|
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace cv;
Mat src,dst;
int i = 1;
static void change_dst(int, void*)
{
if(i%2 == 0)i++;
blur( src, dst, Size( i, i ), Point(-1,-1));
imshow("dstImage", dst);
}
int main( int, char** argv )
{
src = imread( argv[1] );
namedWindow("srcImage", 1);
namedWindow("dstImage", 1);
createTrackbar( "mean filter:", "dstImage", &i, 20, change_dst);
change_dst(0, 0);
imshow("srcImage", src);
waitKey();
return 0;
}
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace cv;
Mat src,dst;
int i = 1;
static void change_dst(int, void*)
{
if(i%2 == 0)i++;
GaussianBlur( src, dst, Size( i, i ), 0, 0 );
imshow("dstImage", dst);
}
int main( int, char** argv )
{
src = imread( argv[1] );
namedWindow("srcImage", 1);
namedWindow("dstImage", 1);
createTrackbar( "gauss filter:", "dstImage", &i, 20, change_dst);
change_dst(0, 0);
imshow("srcImage", src);
waitKey();
return 0;
}
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace cv;
Mat src,dst,Kernel;
int main( int, char** argv )
{
src = imread( argv[1] );
namedWindow("srcImage", 1);
namedWindow("dstImage", 1);
Kernel = (Mat_<double>(3,3) << 1, 2, 1, 2, 4, 2, 1, 2, 1)/16;
filter2D(src, dst, -1 , Kernel, Point(-1,-1));
imshow("dstImage", dst);
imshow("srcImage", src);
waitKey();
return 0;
}
K =vhT
|
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace cv;
Mat src,dst,kernelX,kernelY;
int main( int, char** argv )
{
src = imread( argv[1] );
namedWindow("srcImage", 1);
namedWindow("dstImage", 1);
kernelX = (Mat_<double>(1,5) << 1,4,6,4,1)/16;
kernelY = (Mat_<double>(1,5) << 1,4,6,4,1)/16;
sepFilter2D(src, dst, -1, kernelX, kernelY);
imshow("dstImage", dst);
imshow("srcImage", src);
waitKey();
return 0;
}
原文地址:http://blog.csdn.net/abcd1992719g/article/details/24625805