Example #1
0
def deskew(img, angle=None, is_binary=True):
    angle = angle or compute_skew(img, is_binary)

    if not angle:
        return img

    image_center = (np.size(img, 1)/2, np.size(img, 0)/2)

    rot_mat = cv2.getRotationMatrix2D(image_center, angle, 1)
    deskewed = cv2.warpAffine(img, rot_mat, (np.size(img, 1), np.size(img, 0)), flags=cv2.INTER_LINEAR)

    if is_binary:
        deskewed = histogram_equalization.binary(deskewed)

    return deskewed
Example #2
0
def deskew(img, angle=None, is_binary=True):
    angle = angle or compute_skew(img, is_binary)

    if not angle:
        return img

    image_center = (np.size(img, 1) / 2, np.size(img, 0) / 2)

    rot_mat = cv2.getRotationMatrix2D(image_center, angle, 1)
    deskewed = cv2.warpAffine(img,
                              rot_mat, (np.size(img, 1), np.size(img, 0)),
                              flags=cv2.INTER_LINEAR)

    if is_binary:
        deskewed = histogram_equalization.binary(deskewed)

    return deskewed
Example #3
0
def binary_detect(img):
    img = histogram_equalization.normal(img)
    img = histogram_equalization.binary(img)
    return img