MCPcopy Create free account
hub / github.com/creatale/node-dv / Init

Method Init

deps/tesseract/classify/intfeaturemap.cpp:73–99  ·  view source on GitHub ↗

Copies the given feature_space and uses it as the index feature map from INT_FEATURE_STRUCT.

Source from the content-addressed store, hash-verified

71// Copies the given feature_space and uses it as the index feature map
72// from INT_FEATURE_STRUCT.
73void IntFeatureMap::Init(const IntFeatureSpace& feature_space) {
74 feature_space_ = feature_space;
75 mapping_changed_ = false;
76 int sparse_size = feature_space_.Size();
77 feature_map_.Init(sparse_size, true);
78 feature_map_.Setup();
79 compact_size_ = feature_map_.CompactSize();
80 // Initialize look-up tables if needed.
81 FCOORD dir = FeatureDirection(0);
82 if (dir.x() == 0.0f && dir.y() == 0.0f)
83 InitIntegerFX();
84 // Compute look-up tables to generate offset features.
85 for (int dir = 0; dir < kNumOffsetMaps; ++dir) {
86 delete [] offset_plus_[dir];
87 delete [] offset_minus_[dir];
88 offset_plus_[dir] = new int[sparse_size];
89 offset_minus_[dir] = new int[sparse_size];
90 }
91 for (int dir = 1; dir <= kNumOffsetMaps; ++dir) {
92 for (int i = 0; i < sparse_size; ++i) {
93 int offset_index = ComputeOffsetFeature(i, dir);
94 offset_plus_[dir - 1][i] = offset_index;
95 offset_index = ComputeOffsetFeature(i, -dir);
96 offset_minus_[dir - 1][i] = offset_index;
97 }
98 }
99}
100
101// Helper to return an offset index feature. In this context an offset
102// feature with a dir of +/-1 is a feature of a similar direction,

Callers 1

FindNZFeatureMappingMethod · 0.45

Calls 7

FeatureDirectionFunction · 0.85
InitIntegerFXFunction · 0.85
SizeMethod · 0.80
SetupMethod · 0.80
CompactSizeMethod · 0.80
xMethod · 0.45
yMethod · 0.45

Tested by

no test coverage detected