Created
April 16, 2021 12:59
-
-
Save NbtKmy/2266ea0fe2771bf899bbf995d602a007 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import cv2 | |
import argparse | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser(description='Pre-process for OCR') | |
parser.add_argument('input', help='Name of original image') | |
parser.add_argument('output', help='Name of output image') | |
args = parser.parse_args() | |
img = cv2.imread(args.input) | |
h, s, grau_img = cv2.split(cv2.cvtColor(img, cv2.COLOR_BGR2HSV)) | |
cv2.imwrite(args.output, grau_img) | |
# Binarisierung | |
ret, bi_img = cv2.threshold(grau_img, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU) | |
res_name2 = 'Binarized' + args.output | |
cv2.imwrite(res_name2, bi_img) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment