【发布时间】:2019-08-03 07:59:36
【问题描述】:
所以,我正在尝试使用以下代码显示只有黑白的二进制图片:
import cv2
import numpy as np
x_img = cv2.imread("lenac.tif")
x_img_g = cv2.cvtColor(x_img, cv2.COLOR_BGR2GRAY)
y = x_img_g > 128
cv2.imshow("", y*1.0)
cv2.waitKey(0)
cv2.destroyAllWindows()
但是我收到了这个错误:
>Traceback (most recent call last):
File "ex5.py", line 11, in <module>
cv2.imshow("", y*1.0)
cv2.error: OpenCV(4.0.0) c:\projects\opencv-
python\opencv\modules\imgproc\src\color.hpp:261: error: (-2:Unspecified
error) >in function '__cdecl cv::CvtHelper<struct
cv::Set<1,-1,-1>,struct cv::Set<3,4,-1>,struct
cv::Set<0,2,5>,2>::CvtHelper(const class cv::_InputArray &,const class
cv::_OutputArray &,int)'
>Unsupported depth of input image:
> 'VDepth::contains(depth)'
> where
> 'depth' is 6 (CV_64F).
【问题讨论】: