Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5967eae

Browse files
Update SamplePreprocessor.py
Add the interpolation of Image details
1 parent 800496e commit 5967eae

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

‎src/SamplePreprocessor.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def preprocessor(img, imgSize, enhance=False, dataAugmentation=False):
2525
pxmin = np.min(img)
2626
pxmax = np.max(img)
2727
imgContrast = (img - pxmin) / (pxmax - pxmin) * 255
28-
# increase line width
28+
# increase line width (optional)
2929
kernel = np.ones((3, 3), np.uint8)
3030
img = cv2.erode(imgContrast, kernel, iterations=1) # increase linewidth
3131

@@ -37,7 +37,8 @@ def preprocessor(img, imgSize, enhance=False, dataAugmentation=False):
3737
f = max(fx, fy)
3838
newSize = (max(min(wt, int(w / f)), 1),
3939
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
4142
target = np.ones([ht, wt]) * 255 # shape=(64,800)
4243
target[0:newSize[1], 0:newSize[0]] = img
4344

@@ -92,4 +93,4 @@ def wer(r, h):
9293
insertion = d[i][j-1] + 1
9394
deletion = d[i-1][j] + 1
9495
d[i][j] = min(substitution, insertion, deletion)
95-
return d[len(r)][len(h)]
96+
return d[len(r)][len(h)]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /