关于#python#的问题:histr = cv.calcHist([img], [i], None, [256], [0, 256])

使用opencv函数遇见的问题

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

img = cv.imread('4.jpeg')
color = ('b', 'g', 'r')
for i, col in enumerate(color):
    histr = cv.calcHist([img], [i], None,  [256], [0, 256])
    plt.plot(histr, color=col)
    plt.xlim([0, 256])
plt.show()


cv2.error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\histogram.cpp:160: error: (-215:Assertion failed) j < nimages in function 'cv::histPrepareImages