1 | initial version |
basically, 3 steps, (assuming your image is 'ocv'):
# 1. invert it. mnist needs white numbers on white bg
ocv = ~ocv
# 2. crop the inner rectangle:
BH = 19 # border
BV = 21 # border
ocv = ocv[BH:-BH, BV:-BV]
#3. resize to what mnist wants:
ocv = cv2.resize(ocv, (28,28))