|
Tesseract
3.02
|
#include <intfeaturemap.h>
Public Member Functions | |
| IntFeatureMap () | |
| ~IntFeatureMap () | |
| int | sparse_size () const |
| int | compact_size () const |
| const IntFeatureSpace & | feature_space () const |
| const IndexMapBiDi & | feature_map () const |
| int | IndexFeature (const INT_FEATURE_STRUCT &f) const |
| int | MapFeature (const INT_FEATURE_STRUCT &f) const |
| int | MapIndexFeature (int index_feature) const |
| INT_FEATURE_STRUCT | InverseIndexFeature (int index_feature) const |
| INT_FEATURE_STRUCT | InverseMapFeature (int map_feature) const |
| void | DeleteMapFeature (int map_feature) |
| bool | IsMapFeatureDeleted (int map_feature) const |
| void | Init (const IntFeatureSpace &feature_space) |
| int | OffsetFeature (int index_feature, int dir) const |
| int | FindNZFeatureMapping (SampleIterator *it) |
| int | FinalizeMapping (SampleIterator *it) |
| void | IndexAndSortFeatures (const INT_FEATURE_STRUCT *features, int num_features, GenericVector< int > *sorted_features) const |
| int | MapIndexedFeatures (const GenericVector< int > &index_features, GenericVector< int > *map_features) const |
| void | DebugMapFeatures (const GenericVector< int > &map_features) const |
Definition at line 48 of file intfeaturemap.h.
| tesseract::IntFeatureMap::IntFeatureMap | ( | ) |
Definition at line 35 of file intfeaturemap.cpp.
| tesseract::IntFeatureMap::~IntFeatureMap | ( | ) |
Definition at line 43 of file intfeaturemap.cpp.
{
Clear();
}
| int tesseract::IntFeatureMap::compact_size | ( | ) | const [inline] |
Definition at line 57 of file intfeaturemap.h.
{
return compact_size_;
}
| void tesseract::IntFeatureMap::DebugMapFeatures | ( | const GenericVector< int > & | map_features | ) | const |
Definition at line 173 of file intfeaturemap.cpp.
{
for (int i = 0; i < map_features.size(); ++i) {
INT_FEATURE_STRUCT f = InverseMapFeature(map_features[i]);
f.print();
}
}
| void tesseract::IntFeatureMap::DeleteMapFeature | ( | int | map_feature | ) |
Definition at line 64 of file intfeaturemap.cpp.
{
feature_map_.Merge(-1, map_feature);
mapping_changed_ = true;
}
| const IndexMapBiDi& tesseract::IntFeatureMap::feature_map | ( | ) | const [inline] |
Definition at line 63 of file intfeaturemap.h.
{
return feature_map_;
}
| const IntFeatureSpace& tesseract::IntFeatureMap::feature_space | ( | ) | const [inline] |
Definition at line 60 of file intfeaturemap.h.
{
return feature_space_;
}
| int tesseract::IntFeatureMap::FinalizeMapping | ( | SampleIterator * | it | ) |
Definition at line 160 of file intfeaturemap.cpp.
{
if (mapping_changed_) {
feature_map_.CompleteMerges();
compact_size_ = feature_map_.CompactSize();
#ifdef EXPERIMENT_ON
it->MapSampleFeatures(*this);
#endif
mapping_changed_ = false;
}
return compact_size_;
}
| int tesseract::IntFeatureMap::FindNZFeatureMapping | ( | SampleIterator * | it | ) |
| void tesseract::IntFeatureMap::IndexAndSortFeatures | ( | const INT_FEATURE_STRUCT * | features, |
| int | num_features, | ||
| GenericVector< int > * | sorted_features | ||
| ) | const [inline] |
Definition at line 104 of file intfeaturemap.h.
{
feature_space_.IndexAndSortFeatures(features, num_features,
sorted_features);
}
| int tesseract::IntFeatureMap::IndexFeature | ( | const INT_FEATURE_STRUCT & | f | ) | const |
Definition at line 48 of file intfeaturemap.cpp.
{
return feature_space_.Index(f);
}
| void tesseract::IntFeatureMap::Init | ( | const IntFeatureSpace & | feature_space | ) |
Definition at line 74 of file intfeaturemap.cpp.
{
feature_space_ = feature_space;
mapping_changed_ = false;
int sparse_size = feature_space_.Size();
feature_map_.Init(sparse_size, true);
feature_map_.Setup();
compact_size_ = feature_map_.CompactSize();
// Initialize look-up tables if needed.
FCOORD dir = FeatureDirection(0);
if (dir.x() == 0.0f && dir.y() == 0.0f)
InitIntegerFX();
// Compute look-up tables to generate offset features.
for (int dir = 0; dir < kNumOffsetMaps; ++dir) {
delete [] offset_plus_[dir];
delete [] offset_minus_[dir];
offset_plus_[dir] = new int[sparse_size];
offset_minus_[dir] = new int[sparse_size];
}
for (int dir = 1; dir <= kNumOffsetMaps; ++dir) {
for (int i = 0; i < sparse_size; ++i) {
int offset_index = ComputeOffsetFeature(i, dir);
offset_plus_[dir - 1][i] = offset_index;
offset_index = ComputeOffsetFeature(i, -dir);
offset_minus_[dir - 1][i] = offset_index;
}
}
}
| INT_FEATURE_STRUCT tesseract::IntFeatureMap::InverseIndexFeature | ( | int | index_feature | ) | const |
Definition at line 57 of file intfeaturemap.cpp.
{
return feature_space_.PositionFromIndex(index_feature);
}
| INT_FEATURE_STRUCT tesseract::IntFeatureMap::InverseMapFeature | ( | int | map_feature | ) | const |
Definition at line 60 of file intfeaturemap.cpp.
{
int index = feature_map_.CompactToSparse(map_feature);
return feature_space_.PositionFromIndex(index);
}
| bool tesseract::IntFeatureMap::IsMapFeatureDeleted | ( | int | map_feature | ) | const |
Definition at line 68 of file intfeaturemap.cpp.
{
return feature_map_.IsCompactDeleted(map_feature);
}
| int tesseract::IntFeatureMap::MapFeature | ( | const INT_FEATURE_STRUCT & | f | ) | const |
Definition at line 51 of file intfeaturemap.cpp.
{
return feature_map_.SparseToCompact(feature_space_.Index(f));
}
| int tesseract::IntFeatureMap::MapIndexedFeatures | ( | const GenericVector< int > & | index_features, |
| GenericVector< int > * | map_features | ||
| ) | const [inline] |
Definition at line 115 of file intfeaturemap.h.
{
return feature_map_.MapFeatures(index_features, map_features);
}
| int tesseract::IntFeatureMap::MapIndexFeature | ( | int | index_feature | ) | const |
Definition at line 54 of file intfeaturemap.cpp.
{
return feature_map_.SparseToCompact(index_feature);
}
| int tesseract::IntFeatureMap::OffsetFeature | ( | int | index_feature, |
| int | dir | ||
| ) | const |
Definition at line 114 of file intfeaturemap.cpp.
{
if (dir > 0 && dir <= kNumOffsetMaps)
return offset_plus_[dir - 1][index_feature];
else if (dir < 0 && -dir <= kNumOffsetMaps)
return offset_minus_[-dir - 1][index_feature];
else if (dir == 0)
return index_feature;
else
return -1;
}
| int tesseract::IntFeatureMap::sparse_size | ( | ) | const [inline] |
Definition at line 54 of file intfeaturemap.h.
{
return feature_space_.Size();
}