Home How to implement a kernel of size 1 in a Gaussian filter in opencv?
Reply: 1

How to implement a kernel of size 1 in a Gaussian filter in opencv?

Denis
1#
Denis Published in 2018-02-13 06:18:08Z

I'm trying to create a 1 pixel kernel:

x = cv2.getGaussianKernel(1, 2)

And I use it in a gaussian filter:

blur = cv2.GaussianBlur(img, x, 0)

As a result, an error occurs:

SystemError: new style getargs format but argument is not a tuple

How to fix this error?

janu777
2#
janu777 Reply to 2018-02-13 08:56:26Z

You cannot pass a kernel to the GaussianBlur function. You must pass the kernel size.

So x should be a tuple like (5,5) or (3,3) etc

Also the kernel size values should be Odd and positive and can differ. You cannot use the size(1,2) since 2 is even.

If you want to see the Gaussian kernel use this:

cv2.getGaussianKernel(ksize, sigma[, ktype]) 

EX:

kernel = cv2.getGaussianKernel(ksize=(1,1),sigma=2)

If you want to blur the image using the kernel then use this:

cv2.GaussianBlur(src, ksize, sigmaX[, dst[, sigmaY[, borderType]]])

EX:

cv2.GaussianBlur(src, ksize=(1,1))

check this

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.29941 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO