我正在从像这样的字符串中读取图像。我知道图像是灰度的。
nparr = np.fromstring(image_string, np.uint8)
roi = cv2.imdecode(nparr,cv2.IMREAD_GRAYSCALE)
但是,当我得到shape
图像的图像时,我得到了一个错误
h,w,d = roi.shape #gives error
我得到的错误是:
h, w, d = roi.shape
ValueError: need more than 2 values to unpack
如果更改cv2.IMREAD_GRAYSCALE
为,cv2.IMREAD_COLOR
则不会出现错误,但我相信这样做会稍微改变我的图像,因为在对其进行进一步处理时会得到不同的结果。
roi.shape
只有两个值。
nparr = np.fromstring(image_string, np.uint8)
roi = cv2.imdecode(nparr, cv2.IMREAD_GRAYSCALE)
h, w = roi.shape
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句