错误 AttributeError: 'NoneType' object has no attribute 'astype'
程序员文章站
2024-03-25 11:37:04
...
# 自定义函数数高斯模糊
import cv2 as cv
import numpy as np
from matplotlib import pyplot as plt
path = 'main.jpg'
img = cv.imread(path, 0)
# 自定义 根据窗口大小(10, 10)来计算高斯函数标准差
kernel_size = (7, 7)
sigma = 2
blur = cv.GaussianBlur(img, kernel_size, sigma)
img_new = blur.astype(np.uint8)
plt.subplot(121), plt.imshow(img), plt.title('main')
plt.xticks(), plt.yticks()
plt.subplot(122), plt.imshow(blur), plt.title('median')
plt.xticks(), plt.yticks()
plt.show()
# cv.imshow('img', blur)
# cv.waitKey(0)
错误原因:path的路径中没有对应的图片,所以类型当然为空了~~~
推荐阅读
-
AttributeError: 'NoneType' object has no attribute 'find_all'
-
错误 AttributeError: 'NoneType' object has no attribute 'astype'
-
在Django框架中偶遇报错:AttributeError: ‘str’ object has no attribute ‘decode’解决办法
-
Django 报错:‘AttributeError: ‘str‘ object has no attribute ‘decode‘‘
-
AttributeError: ‘NoneType‘ object has no attribute ‘name‘
-
【已解决】python-pip升级报错- AttributeError: 'NoneType' object has no attribute 'bytes'
-
AttributeError: ‘str‘ object has no attribute ‘decode‘ Python3
-
Django2.2报错::AttributeError: ''str'' object has no attribute ''decode''
-
pip 升级问题 'NoneType' object has no attribute 'bytes' 博客分类: python
-
Python3下错误AttributeError: ‘dict’ object has no attribute’iteritems‘的分析与解决