ImageExtractor.py 文件源码

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

项目:SudokuSolver 作者: Anve94 项目源码 文件源码
def to_binary(self, image):
        """ This method uses Adaptive Thresholding to convert
            a blurred grayscale image to binary (only black and white).
            The binary image is required to extract the full sudoku grid
            from the image. """
        if ENABLE_DEBUG:
                print("DEBUG -- Attempting to apply adaptive threshold"
                      " and convert image to black and white.")
        try:
            thresh = cv2.adaptiveThreshold(image, 255, 1, 1, 11, 2)
        except:
            if VERBOSE_EXIT:
                print("ERROR -- Unable to convert the image to black/white."
                      " Please contact the developer at %s and include this"
                      " error and the image you are using." % DEV_EMAIL)
            exit()
        if ENABLE_PREVIEW or ENABLE_PREVIEW_ALL:
            image_preview(thresh)
        if ENABLE_DEBUG:
            print("DEBUG -- Image succesfully converted to binary.")
        return thresh
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号