Opencv2.4 learning:: Filtering (2) Median filtering

Filter series:

  1. 均值过滤

  2. 中值过滤
  3. 高斯过滤网
  4. bilateral filter

中Value Filter

C++: void medianBlur(InputArray src, OutputArray dst, int ksize)
  • InputArray src: Input image, the image is 1, 3, 4 channel image, when the template size is 3 or 5, the image depth can only be one of CV_8U, CV_16U, CV_32F, for example For large aperture size images, the image depth can only be CV_8U.
  • OutputArray dst: The output image, size and type are the same as the input image. You can use Mat::Clone to initialize the output image with the original image as a template. dst
  • int ksize: The size of the filter template must be odd.

call code:

#include<opencv2/core/core.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<iostream>
using namespace std;
using namespace cv;
void main()
{
	Mat srcImage = imread("F:\\opencv_re_learn\\2.jpg");
	if (!srcImage.data){
		cout << "falied to read" << endl;
		system("pause");
		return;
	}
	imshow("srcImage", srcImage);
	Mat blurImage;
	medianBlur(srcImage, blurImage, 3);
	imshow("medianblur", blurImage);
	waitKey(0);
}

achieve effect: