scan2.py 文件源码

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

项目:card-scanner 作者: RFVenter 项目源码 文件源码
def contrast_image(image, thresh1=180, thresh2=200, show=False):
    image = imutils.resize(image, height=scale_factor)
    # convert it to grayscale, and blur it slightly
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    gray2 = cv2.GaussianBlur(gray, (5, 5), 0)

    # threshold the image, then perform a series of erosions + dilations to remove any small regions of noise
    thresh = cv2.threshold(gray2, thresh1, thresh2, cv2.THRESH_BINARY)[1]
    thresh2 = cv2.erode(thresh, None, iterations=2)
    thresh3 = cv2.dilate(thresh2, None, iterations=2)

    if show is True: #this is for debugging puposes
        cv2.imshow("Contrast", thresh3)
        cv2.waitKey(0)
        cv2.destroyAllWindows()

    return thresh
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号