Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
337 B
1
Indexable
def preprocess(img):
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    blur = cv2.blur(gray,(3,3))
    _, thresh = cv2.threshold(blur, 240, 255, cv2.THRESH_BINARY)
    thresh = cv2.bitwise_not(thresh)
    element = cv2.getStructuringElement(shape=cv2.MORPH_RECT, ksize=(5,5))
    erode = cv2.erode(thresh, element, 3)
    return erode