python:不支持图像的OpenCV深度(CV_64F)

时间:2019-03-12 18:26:49

标签: python numpy opencv

因此,我尝试使用此代码显示仅黑白图像的二进制图片:

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).

0 个答案:

没有答案