我已经通过使用skimage库中的“ img_as_float”将图片转换为浮动图片,以获取区域最大值,但是在阈值设置时出现了此错误
cv2.error: OpenCV(3.4.4) C:\projects\opencv-python\opencv\modules\imgproc\src\thresh.cpp:1406: error: (-215:Assertion failed) src.type() == CV_8UC1 in function 'cv::threshold'
我已经搜索了此错误,这意味着我必须使用灰度图像作为此功能的输入。我检查了一下,发现图像是灰度格式的。
img7 = img_as_float(img6)
img8 = gaussian_filter(img7, 1)
h= 0.4
seed = img8 - h
mask = img8
dilated = reconstruction(seed, mask, method='dilation')
final = img8 - dilated
gaussian_blur = cv2.GaussianBlur(final,(3,3),0)
r,img10 = cv2.threshold(gaussian_blur,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)