tesseract 4.1.1
Loading...
Searching...
No Matches
generate_lut.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2
3# Create C/C++ code for two lookup tables.
4
5import math
6
7# Size of static tables.
8kTableSize = 4096
9# Scale factor for float arg to int index.
10kScaleFactor = 256.0
11
12print("// Generated code with lookup tables")
13print('#include "functions.h"')
14print("namespace tesseract {")
15
16print("const double TanhTable[] = {")
17for i in range(kTableSize):
18 print(" %a," % math.tanh(i / kScaleFactor))
19print("};")
20
21print("const double LogisticTable[] = {")
22for i in range(kTableSize):
23 print(" %a," % (1 / (1 + math.exp(-i / kScaleFactor))))
24print("};")
25print("} // namespace tesseract.")