"system Error: New Style Getargs Format But Argument Is Not A Tuple" When Using Cv2.blur
Solution 1:
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.
So make code like this :
im = cv2.imread('./test_imgs/zzzyj.jpg')
cv2.imshow('Image', cv2.blur(im, (3,3)))
cv2.waitKey(0)
cv2.destroyAllWindows()
Hope it will work!!!
Solution 2:
I have got the same issue when upgrading Pillow from 2.8.1
to 4.1.0
.
Here is a piece of example code that will generate the exception when running Pillow==4.1.0
:
from PIL import Image
img = Image.new('RGBA', [100,100])
# An empty mask is created to later overlay the original image (img)
mask = Image.new('L', img.size, 255)
# Get transparency (mask) layer pixels, they will be changed!
data = mask.load()
# The function used laterdeffoo(x,y): returnround(1.0*x/(y+1))
# Update all pixels in the mask according to some function (foo)for x inrange(img.size[0]):
for y inrange(img.size[1]):
data[x,y] = foo(x,y)
Output:
Traceback (most recent call last):
File "x.py", line 12, in <module>
data[x,y] = foo(x,y)
SystemError:new style getargs format but argument isnot a tuple
The actual error here has nothing to do with what is stated in the exception. It is actually the type of the data assigned to data that is wrong. In 2.8.1
both int
and float
are valid, so things like data[x,y]=1.0
is valid, while in 4.1.0
you need to use integers like any of this:
data[x,y]=1data[x,y]=int(1.0)
So in the example above foo
could be redefined to the following to work in both 2.8.1
and 4.1.0
.:
deffoo(x,y): returnint(round(1.0*x/(y+1)))
Post a Comment for ""system Error: New Style Getargs Format But Argument Is Not A Tuple" When Using Cv2.blur"