Skip to content

Instantly share code, notes, and snippets.

View NicoLivesey's full-sized avatar
🎯
Focusing

Nicolas Henry NicoLivesey

🎯
Focusing
View GitHub Profile
@NicoLivesey
NicoLivesey / deskew.py
Created December 14, 2018 12:18
Simple version of deskewing
import sys
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image as im
from scipy.ndimage import interpolation as inter
input_file = sys.argv[1]
img = im.open(input_file)
@NicoLivesey
NicoLivesey / baseline_ocr.py
Created December 13, 2018 11:09
Simple baseline to apply ocr
def remove_clear(img, degree):
'''
Preprocess l'image avant l'algo de détection de texte de manière à avoir une image thresholdée optimale
'''
# img = cv2.bilateralFilter(img, degree, 75, 75)
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
img = cv2.adaptiveThreshold(img, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C,\
cv2.THRESH_BINARY,65,11)
# _, img = cv2.threshold(img,170,255,cv2.THRESH_BINARY)