Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何正确使用cv2实现高斯模糊?_Python_Image Processing_Cv2 - Fatal编程技术网

Python 如何正确使用cv2实现高斯模糊?

Python 如何正确使用cv2实现高斯模糊?,python,image-processing,cv2,Python,Image Processing,Cv2,我得到以下错误 error Traceback (most recent call last) <ipython-input-10-2d3a348b0b9b> in <module>() 25 26 #gaussian blur (sigma = 1) ---> 27 gaus_blur1 = cv2.GaussianBlur(img,(0,0), 1, 1) 2

我得到以下错误

error                                     Traceback (most recent call last)
<ipython-input-10-2d3a348b0b9b> in <module>()
     25 
     26 #gaussian blur (sigma = 1)
---> 27 gaus_blur1 = cv2.GaussianBlur(img,(0,0), 1, 1)
     28 cv2_imshow(gaus_blur1[2000])
     29 

error: OpenCV(4.1.2) /io/opencv/modules/core/src/matrix.cpp:757: error: (-215:Assertion failed) dims <= 2 && step[0] > 0 in function 'locateROI'

大多数在线解决方案都提到没有从文件夹中正确读取图像,但事实并非如此,我尝试绘制了一些图像,数据集正是这样。你知道它可能是什么吗?

虽然你的问题中缺乏背景还不能很清楚地说明问题,但你似乎在试图模糊图像阵列,而不是一幅2D图像

单独模糊每个图像:

# could be some other structure than dicts, but it's not clear from the question
img = {}  
gaus_blur = {}

for k in range(7165):
    image = cv2.imread("/content/FIGURE/figure" + str(k) + ".png", 1)
    img[k] = image  # store original image
    gaus_blur[k] = cv2.GaussianBlur(255 - image, (0, 0), 1, 1)  # store inverse blurred image



哪一行代码会给你这个错误?请显示完整的回溯,而不仅仅是错误。@AKX我编辑了它。误差由cv2.GaussianBlur给出,它自己起作用
img
gausu-blur
被定义为
np.empty
向量。唯一的办法就是把它们弄得模糊不清。非常感谢。
# could be some other structure than dicts, but it's not clear from the question
img = {}  
gaus_blur = {}

for k in range(7165):
    image = cv2.imread("/content/FIGURE/figure" + str(k) + ".png", 1)
    img[k] = image  # store original image
    gaus_blur[k] = cv2.GaussianBlur(255 - image, (0, 0), 1, 1)  # store inverse blurred image