morphology_utils.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:Shoe-Shape-Classifier 作者: jrzaurin 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号