main.py 文件源码

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

项目:SudokuVisionSolver 作者: tusharsircar95 项目源码 文件源码
def centerDigit(img):
    xMean,yMean,count = 0,0,0
    (x,y) = np.shape(img)
    for i in range(x):
        for j in range(y):
            if img[i][j] == 255:
                xMean,yMean,count = (xMean+i),(yMean+j),(count+1)
    if count == 0:
        return img

    xMean,yMean = (xMean / count),(yMean / count)
    xDisp,yDisp = (xMean - (x/2)),(yMean - (y/2))

    newImg = np.zeros((x,y),np.uint8)
    for i in range(x):
        for j in range(y):
            if img[i][j] == 255:
                newImg[i-xDisp][j-yDisp] = 255
    return newImg

# Given the cropped out digit, places it on a black background for matching with templates
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号