idcard.py 文件源码

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

项目:dust_repos 作者: taozhijiang 项目源码 文件源码
def img_sobel_binary(im, blur_sz):

    # ??????????????
    img_blur = cv2.GaussianBlur(im,blur_sz,0)
    if len(img_blur.shape) == 3:
        blur_gray = cv2.cvtColor(img_blur,cv2.COLOR_BGR2GRAY) 
    else:
        blur_gray = img_blur

    # ??Sobel????
    sobelx = cv2.Sobel(blur_gray,cv2.CV_16S,1,0,ksize=3)
    abs_sobelx = np.absolute(sobelx)
    sobel_8u = np.uint8(abs_sobelx)
    img_show_hook("Sobel??", sobel_8u)

    # OTSU??????    
    ret, thd = cv2.threshold(sobel_8u, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)    
    thd_abs = cv2.convertScaleAbs(thd)
    bgimg = cv2.addWeighted(thd_abs, 1, 0, 0, 0)

    img_show_hook("OTSU????", bgimg)

    return bgimg
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号