Search code examples
pythonopencvmedian

Python (OpenCV) Median filter trouble


I need to do a (fast) median filter of some images from Python, and after some time on Google it seems like OpenCV is the way to go for speed (even in Python). I got OpenCV up and running, and filters like Erode and Dilate works fine:

cv.Erode(cv_im,cv_im,None,6)
cv.Dilate(cv_im,cv_im,None,6)

The Median filter, however, does not seem to work:

cv.Smooth(cv_im,cv_im,CV_MEDIAN)

"NameError: global name 'CV_MEDIAN' is not defined"

I can't seem to figure out what I'm doing wrong, according to the documentation http://opencv.willowgarage.com/documentation/python/image_filtering.html#smooth it looks like I do it the correct way.

Any ideas? Many thanks in advance!


Solution

  • Looks like you imported pyopencv as "cv". So you editting CV_MEDIAN to cv.CV_MEDIAN should help