Ask Your Question

Revision history [back]

Here:

#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"

using namespace std;
using namespace cv;

int main( int argc, char** argv )
 {

     Mat src = imread( "salt.tif", 1 );
     Mat dst;

     //Apply median filter
     medianBlur ( src, dst, 39 );
     imshow("source", src);
     imshow("result", dst);  

     waitKey(0);
     return 0;
 }

I must give credit to this blog post:

http://opencvexamples.blogspot.com/2013/10/applying-median-filter.html#.U6SgVvmSxqU

Also see to documentation:

http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=medianblur#medianblur

Gil