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:

using namespace std;
using namespace cv;
void main()
	Mat srcImage = imread("F:\\opencv_re_learn\\2.jpg");
	if (!{
		cout << "falied to read" << endl;
	imshow("srcImage", srcImage);
	Mat blurImage;
	medianBlur(srcImage, blurImage, 3);
	imshow("medianblur", blurImage);

achieve effect: