错误 AttributeError: 'NoneType' object has no attribute 'ravel'

AttributeError: ‘NoneType’ object has no attribute ‘ravel’

import cv2 as cv
from matplotlib import pyplot as plt
import numpy as np


path = './water_bottle/main.jpg'
img = cv.imread(path, 0)
plt.hist(img.ravel(), 256, [0, 256])
plt.show()

  • 可能原因
    • 没有numpy这个库
    • 没有引入import numpy或者import numpy as np
    • path的路径中没有这张图片或者就是路径错误,img中没有对应的值

猜你喜欢

转载自blog.csdn.net/zhangyu4863/article/details/81181196
今日推荐