@@ -25,7 +25,7 @@ def preprocessor(img, imgSize, enhance=False, dataAugmentation=False):
25
25
pxmin = np .min (img )
26
26
pxmax = np .max (img )
27
27
imgContrast = (img - pxmin ) / (pxmax - pxmin ) * 255
28
- # increase line width
28
+ # increase line width (optional)
29
29
kernel = np .ones ((3 , 3 ), np .uint8 )
30
30
img = cv2 .erode (imgContrast , kernel , iterations = 1 ) # increase linewidth
31
31
@@ -37,7 +37,8 @@ def preprocessor(img, imgSize, enhance=False, dataAugmentation=False):
37
37
f = max (fx , fy )
38
38
newSize = (max (min (wt , int (w / f )), 1 ),
39
39
max (min (ht , int (h / f )), 1 )) # scale according to f (result at least 1 and at most wt or ht)
40
- img = cv2 .resize (img , newSize )
40
+ img = cv2 .resize (img , newSize , interpolation = cv2 .INTER_CUBIC ) # INTER_CUBIC interpolation best approximate the pixels image
41
+ # see this https://stackoverflow.com/a/57503843/7338066
41
42
target = np .ones ([ht , wt ]) * 255 # shape=(64,800)
42
43
target [0 :newSize [1 ], 0 :newSize [0 ]] = img
43
44
@@ -92,4 +93,4 @@ def wer(r, h):
92
93
insertion = d [i ][j - 1 ] + 1
93
94
deletion = d [i - 1 ][j ] + 1
94
95
d [i ][j ] = min (substitution , insertion , deletion )
95
- return d [len (r )][len (h )]
96
+ return d [len (r )][len (h )]
0 commit comments