def threshold_img(img):
"""
Simple wrap-up function for cv2.threshold()
"""
is_color = len(img.shape) == 3
is_grey = len(img.shape) == 2
t = threshold_value(img)
if is_color:
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
elif is_grey:
gray = img.copy()
blurred = cv2.GaussianBlur(gray, (3, 3), 0)
(_, thresh) = cv2.threshold(blurred, t*255, 1, cv2.THRESH_BINARY_INV)
return thresh
morphology_utils.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录