问题描述
我只是尝试使用cv2(opencv python绑定)将过滤器应用于图像。以下是我的代码:
I am just trying to apply a filter to an image using cv2, the opencv python bindings. Here is what my code look like:
im = cv2.imread('./test_imgs/zzzyj.jpg')
cv2.imshow('Image', cv2.blur(im, 2)
cv2.waitKey(0)
它几乎是从。但是,它只是不起作用,没有比此消息更多的跟踪:
It's almost copy-and-paste from the documentation. However, it just doesn't work, with no more trace than this message:
SystemError: new style getargs format but argument is not a tuple
GaussianBlur也会出现同样的错误,但不会出现中位数。任何想法?
The same error occurs with GaussianBlur, but not with medianBlur. Any thoughts?
推荐答案
对于cv2.blur,你需要将ksize作为两个元素的元组,如(2,2)。但是对于medianBlur,ksize = 3就足够了。它将从中扣除一个方形内核。
For cv2.blur, you need to give ksize as a tuple of two elements , like (2,2). But for medianBlur, ksize = 3 is sufficient. It will deduct a square kernel from it.
所以制作如下代码:
im = cv2.imread('./test_imgs/zzzyj.jpg')
cv2.imshow('Image', cv2.blur(im, (3,3)))
cv2.waitKey(0)
cv2.destroyAllWindows()
希望它能起作用!!!
Hope it will work!!!
这篇关于“系统错误:新样式的getargs格式,但参数不是元组”当使用cv2.blur时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!