Median filter greater than 5.

Hi,

how can I efficiently implement a median filter with kernel size greater than 5. In my case I use float data. In partucular, I need a median filter with kernel size equal to 39.

Thanks

edit retag close merge delete

Sort by ยป oldest newest most voted

Linear complexity median filter (such as OpenCV's 8-bit single and multichannel versions) is based on a moving histogram implementation. Naturally for floating point, there is none or it would be close to infinite sized histogram. Simplest workaround would be discretization - say - to 8-bit :) if that suits you. Or then increasing the number of bins in a custom way.

You can follow one of these guidelines or just implement O(N^3) version yourself. The last N comes from the search using std::nth_element in a neighborhood of N^2.

more

I haven;t tried it, but have a look here, it is the same algorithm as openCV's however it is extended to 16 bits per pixel,

https://github.com/aoles/EBImage/blob...

more

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

more

I can use a median filter graeter than 5 for CV_8U depth image, but not for a CV_32F image. I need to filter an CV_32F image using a median filter with kernel size equal or greater than 40.

more