[fb1bbb]: / backend / src / util.py

Download this file

15 lines (14 with data), 401 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
import numpy as np
import cv2
def preprocess_image(img):
gray = cv2.cvtColor(np.array(img), cv2.COLOR_BGR2GRAY)
resized = cv2.resize(gray, None, fx=1.5, fy=1.5, interpolation=cv2.INTER_LINEAR)
processed_imaage = cv2.adaptiveThreshold(
resized,
255,
cv2.ADAPTIVE_THRESH_GAUSSIAN_C,
cv2.THRESH_BINARY,
61,
11
)
return processed_imaage