Reputation: 95
I tried all the possibilities using the following instruction:
ret,thresh = cv2.threshold(img,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
But it always gives me the same error:
error: (-215) src.type() == CV_8UC1 in function cv::threshold
There is a possibility to threshold an image 32-bit, single channel ??! Thanks in advance
Upvotes: 1
Views: 5076
Reputation: 41765
According to OpenCV doc for cv::threshold:
Currently, the Otsu’s method is implemented only for 8-bit (
CV_8UC1
) images.
For other methods, according to the documentation, are valid single-channel matrices, 8-bit (CV_8UC1
) or 32-bit floating point (CV_32FC1
).
However, it should work also for 16-bit (CV_16SC1
) matrices
For cv::adaptiveThreshold
, type must be CV_8UC1
.
Upvotes: 2