22 #include "config_auto.h" 53 #define offset_table_entries \ 54 255, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, \ 55 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, \ 56 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, 0, 1, 0, 2, 0, 1, 0, 3, \ 57 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, \ 58 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, \ 59 0, 1, 0, 2, 0, 1, 0, 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, \ 60 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, \ 61 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, \ 62 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, \ 63 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, \ 64 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 66 #define INTMATCHER_OFFSET_TABLE_SIZE 256 68 #define next_table_entries \ 69 0, 0, 0, 0x2, 0, 0x4, 0x4, 0x6, 0, 0x8, 0x8, 0x0a, 0x08, 0x0c, 0x0c, 0x0e, \ 70 0, 0x10, 0x10, 0x12, 0x10, 0x14, 0x14, 0x16, 0x10, 0x18, 0x18, 0x1a, \ 71 0x18, 0x1c, 0x1c, 0x1e, 0, 0x20, 0x20, 0x22, 0x20, 0x24, 0x24, 0x26, \ 72 0x20, 0x28, 0x28, 0x2a, 0x28, 0x2c, 0x2c, 0x2e, 0x20, 0x30, 0x30, 0x32, \ 73 0x30, 0x34, 0x34, 0x36, 0x30, 0x38, 0x38, 0x3a, 0x38, 0x3c, 0x3c, 0x3e, \ 74 0, 0x40, 0x40, 0x42, 0x40, 0x44, 0x44, 0x46, 0x40, 0x48, 0x48, 0x4a, \ 75 0x48, 0x4c, 0x4c, 0x4e, 0x40, 0x50, 0x50, 0x52, 0x50, 0x54, 0x54, 0x56, \ 76 0x50, 0x58, 0x58, 0x5a, 0x58, 0x5c, 0x5c, 0x5e, 0x40, 0x60, 0x60, 0x62, \ 77 0x60, 0x64, 0x64, 0x66, 0x60, 0x68, 0x68, 0x6a, 0x68, 0x6c, 0x6c, 0x6e, \ 78 0x60, 0x70, 0x70, 0x72, 0x70, 0x74, 0x74, 0x76, 0x70, 0x78, 0x78, 0x7a, \ 79 0x78, 0x7c, 0x7c, 0x7e, 0, 0x80, 0x80, 0x82, 0x80, 0x84, 0x84, 0x86, \ 80 0x80, 0x88, 0x88, 0x8a, 0x88, 0x8c, 0x8c, 0x8e, 0x80, 0x90, 0x90, 0x92, \ 81 0x90, 0x94, 0x94, 0x96, 0x90, 0x98, 0x98, 0x9a, 0x98, 0x9c, 0x9c, 0x9e, \ 82 0x80, 0xa0, 0xa0, 0xa2, 0xa0, 0xa4, 0xa4, 0xa6, 0xa0, 0xa8, 0xa8, 0xaa, \ 83 0xa8, 0xac, 0xac, 0xae, 0xa0, 0xb0, 0xb0, 0xb2, 0xb0, 0xb4, 0xb4, 0xb6, \ 84 0xb0, 0xb8, 0xb8, 0xba, 0xb8, 0xbc, 0xbc, 0xbe, 0x80, 0xc0, 0xc0, 0xc2, \ 85 0xc0, 0xc4, 0xc4, 0xc6, 0xc0, 0xc8, 0xc8, 0xca, 0xc8, 0xcc, 0xcc, 0xce, \ 86 0xc0, 0xd0, 0xd0, 0xd2, 0xd0, 0xd4, 0xd4, 0xd6, 0xd0, 0xd8, 0xd8, 0xda, \ 87 0xd8, 0xdc, 0xdc, 0xde, 0xc0, 0xe0, 0xe0, 0xe2, 0xe0, 0xe4, 0xe4, 0xe6, \ 88 0xe0, 0xe8, 0xe8, 0xea, 0xe8, 0xec, 0xec, 0xee, 0xe0, 0xf0, 0xf0, 0xf2, \ 89 0xf0, 0xf4, 0xf4, 0xf6, 0xf0, 0xf8, 0xf8, 0xfa, 0xf8, 0xfc, 0xfc, 0xfe 95 static const uinT8*
const offset_table = &data_table[0];
96 static const uinT8*
const next_table =
116 max_classes_ = max_classes;
119 class_count_ =
new int[rounded_classes_];
120 norm_count_ =
new int[rounded_classes_];
121 sort_key_ =
new int[rounded_classes_ + 1];
122 sort_index_ =
new int[rounded_classes_ + 1];
123 for (
int i = 0; i < rounded_classes_; i++) {
126 pruning_threshold_ = 0;
132 delete []class_count_;
133 delete []norm_count_;
135 delete []sort_index_;
142 num_features_ = num_features;
144 for (
int f = 0; f < num_features; ++f) {
153 for (
int pruner_set = 0; pruner_set < num_pruners; ++pruner_set) {
156 const uinT32* pruner_word_ptr =
159 uinT32 pruner_word = *pruner_word_ptr++;
212 int cutoff_strength) {
213 for (
int class_id = 0; class_id < max_classes_; ++class_id) {
214 if (num_features_ < expected_num_features[class_id]) {
215 int deficit = expected_num_features[class_id] - num_features_;
216 class_count_[class_id] -= class_count_[class_id] * deficit /
217 (num_features_ * cutoff_strength + deficit);
225 for (
int class_id = 0; class_id < max_classes_; ++class_id) {
227 class_count_[class_id] = 0;
233 for (
int class_id = 0; class_id < max_classes_; ++class_id) {
237 class_count_[class_id] = 0;
247 const uinT8* normalization_factors) {
248 for (
int class_id = 0; class_id < max_classes_; class_id++) {
249 norm_count_[class_id] = class_count_[class_id] -
250 ((norm_multiplier * normalization_factors[class_id]) >> 8);
256 for (
int class_id = 0; class_id < max_classes_; class_id++) {
257 norm_count_[class_id] = class_count_[class_id];
265 bool max_of_non_fragments,
const UNICHARSET& unicharset) {
267 for (
int c = 0; c < max_classes_; ++c) {
268 if (norm_count_[c] > max_count &&
274 (!max_of_non_fragments || !unicharset.
get_fragment(c))) {
275 max_count = norm_count_[c];
279 pruning_threshold_ = (max_count * pruning_factor) >> 8;
281 if (pruning_threshold_ < 1)
282 pruning_threshold_ = 1;
284 for (
int class_id = 0; class_id < max_classes_; class_id++) {
285 if (norm_count_[class_id] >= pruning_threshold_ ||
286 class_id == keep_this) {
288 sort_index_[num_classes_] = class_id;
289 sort_key_[num_classes_] = norm_count_[class_id];
294 if (num_classes_ > 1)
295 HeapSort(num_classes_, sort_key_, sort_index_);
304 int max_num_classes = int_templates->
NumClasses;
305 for (
int f = 0; f < num_features_; ++f) {
307 tprintf(
"F=%3d(%d,%d,%d),", f, feature->
X, feature->
Y, feature->
Theta);
313 for (
int pruner_set = 0; pruner_set < num_pruners; ++pruner_set) {
316 const uinT32* pruner_word_ptr =
319 uinT32 pruner_word = *pruner_word_ptr++;
320 for (
int word_class = 0; word_class < 16 &&
321 class_id < max_num_classes; ++word_class, ++class_id) {
322 if (norm_count_[class_id] >= pruning_threshold_) {
339 const uinT16* expected_num_features,
341 const uinT8* normalization_factors)
const {
342 tprintf(
"CP:%d classes, %d features:\n", num_classes_, num_features_);
343 for (
int i = 0; i < num_classes_; ++i) {
344 int class_id = sort_index_[num_classes_ - i];
347 tprintf(
"%s:Initial=%d, E=%d, Xht-adj=%d, N=%d, Rat=%.2f\n",
349 class_count_[class_id],
350 expected_num_features[class_id],
351 (norm_multiplier * normalization_factors[class_id]) >> 8,
352 sort_key_[num_classes_ - i],
353 100.0 - 100.0 * sort_key_[num_classes_ - i] /
363 for (
int c = 0; c < num_classes_; ++c) {
364 (*results)[c].Class = sort_index_[num_classes_ - c];
365 (*results)[c].Rating = 1.0 - sort_key_[num_classes_ - c] /
385 int rounded_classes_;
387 int pruning_threshold_;
413 int num_features,
int keep_this,
415 const uinT8* normalization_factors,
416 const uinT16* expected_num_features,
423 classify_cp_cutoff_strength);
425 if (shape_table_ == NULL)
432 if (normalization_factors != NULL) {
434 normalization_factors);
439 pruner.
PruneAndSort(classify_class_pruner_threshold, keep_this,
440 shape_table_ == NULL, unicharset);
442 if (classify_debug_level > 2) {
443 pruner.
DebugMatch(*
this, int_templates, features);
445 if (classify_debug_level > 1) {
447 classify_class_pruner_multiplier,
448 normalization_factors);
481 int AdaptFeatureThreshold,
483 bool SeparateDebugWindows) {
488 cprintf (
"Integer Matcher -------------------------------------------\n");
490 tables->
Clear(ClassTemplate);
493 for (Feature = 0; Feature < NumFeatures; Feature++) {
494 int csum = UpdateTablesForFeature(ClassTemplate, ProtoMask, ConfigMask,
495 Feature, &Features[Feature],
502 #ifndef GRAPHICS_DISABLED 504 DebugFeatureProtoError(ClassTemplate, ProtoMask, ConfigMask, *tables,
509 DisplayProtoDebugInfo(ClassTemplate, ProtoMask, ConfigMask,
510 *tables, SeparateDebugWindows);
514 DisplayFeatureDebugInfo(ClassTemplate, ProtoMask, ConfigMask, NumFeatures,
515 Features, AdaptFeatureThreshold, Debug,
516 SeparateDebugWindows);
521 tables->
NormalizeSums(ClassTemplate, NumFeatures, NumFeatures);
523 FindBestMatch(ClassTemplate, *tables, Result);
525 #ifndef GRAPHICS_DISABLED 530 cprintf(
"Match Complete --------------------------------------------\n");
564 int AdaptProtoThreshold,
567 int NumGoodProtos = 0;
572 (
"Find Good Protos -------------------------------------------\n");
574 tables->
Clear(ClassTemplate);
576 for (
int Feature = 0; Feature < NumFeatures; Feature++)
577 UpdateTablesForFeature(
578 ClassTemplate, ProtoMask, ConfigMask, Feature, &(Features[Feature]),
581 #ifndef GRAPHICS_DISABLED 583 DebugFeatureProtoError(ClassTemplate, ProtoMask, ConfigMask, *tables,
588 for (
int proto = 0; proto < ClassTemplate->
NumProtos; proto++) {
591 for (
int i = 0; i < ClassTemplate->
ProtoLengths[proto]; i++)
597 if (Temp >= AdaptProtoThreshold) {
605 cprintf (
"Match Complete --------------------------------------------\n");
608 return NumGoodProtos;
634 int AdaptFeatureThreshold,
637 int NumBadFeatures = 0;
641 cprintf(
"Find Bad Features -------------------------------------------\n");
643 tables->
Clear(ClassTemplate);
645 for (
int Feature = 0; Feature < NumFeatures; Feature++) {
646 UpdateTablesForFeature(
647 ClassTemplate, ProtoMask, ConfigMask, Feature, &Features[Feature],
652 for (
int i = 0; i < ClassTemplate->
NumConfigs; i++)
657 if (best < AdaptFeatureThreshold) {
658 *FeatureArray = Feature;
664 #ifndef GRAPHICS_DISABLED 666 DebugFeatureProtoError(ClassTemplate, ProtoMask, ConfigMask, *tables,
671 cprintf(
"Match Complete --------------------------------------------\n");
674 return NumBadFeatures;
679 classify_debug_level_ = classify_debug_level;
684 double Similarity = ((double) IntSimilarity) / 65536.0 / 65536.0;
685 double evidence = Similarity / kSimilarityCenter;
686 evidence = 255.0 / (evidence * evidence + 1.0);
688 if (kSEExponentialMultiplier > 0.0) {
689 double scale = 1.0 - exp(-kSEExponentialMultiplier) *
690 exp(kSEExponentialMultiplier * ((
double) i / SE_TABLE_SIZE));
694 similarity_evidence_table_[i] = (
uinT8) (evidence + 0.5);
698 evidence_table_mask_ =
699 ((1 << kEvidenceTableBits) - 1) << (9 - kEvidenceTableBits);
700 mult_trunc_shift_bits_ = (14 - kIntEvidenceTruncBits);
701 table_trunc_shift_bits_ = (27 -
SE_TABLE_BITS - (mult_trunc_shift_bits_ << 1));
702 evidence_mult_mask_ = ((1 << kIntEvidenceTruncBits) - 1);
709 memset(sum_feature_evidence_, 0,
710 class_template->
NumConfigs *
sizeof(sum_feature_evidence_[0]));
711 memset(proto_evidence_, 0,
712 class_template->
NumProtos *
sizeof(proto_evidence_[0]));
716 memset(feature_evidence_, 0,
717 class_template->
NumConfigs *
sizeof(feature_evidence_[0]));
731 cprintf (
"F = %3d, P = %3d, E = %3d, Configs = ",
732 FeatureNum, (
int) ActualProtoNum, (
int) Evidence);
750 uinT8 *FeatureEvidence,
752 cprintf(
"F=%3d, C=", FeatureNum);
753 for (
int ConfigNum = 0; ConfigNum < ConfigCount; ConfigNum++) {
754 cprintf(
"%4d", FeatureEvidence[ConfigNum]);
770 int IntegerMatcher::UpdateTablesForFeature(
783 inT32 proto_word_offset;
794 uinT32 ThetaFeatureAddress;
807 XFeatureAddress = ((Feature->
X >> 2) << 1);
811 for (ProtoSetIndex = 0, ActualProtoNum = 0;
812 ProtoSetIndex < ClassTemplate->
NumProtoSets; ProtoSetIndex++) {
813 ProtoSet = ClassTemplate->
ProtoSets[ProtoSetIndex];
814 ProtoPrunerPtr = (
uinT32 *) ((*ProtoSet).ProtoPruner);
816 ProtoNum += (PROTOS_PER_PROTO_SET >> 1), ActualProtoNum +=
817 (PROTOS_PER_PROTO_SET >> 1), ProtoMask++, ProtoPrunerPtr++) {
819 ProtoWord = *(ProtoPrunerPtr + XFeatureAddress);
820 ProtoWord &= *(ProtoPrunerPtr + YFeatureAddress);
821 ProtoWord &= *(ProtoPrunerPtr + ThetaFeatureAddress);
822 ProtoWord &= *ProtoMask;
824 if (ProtoWord != 0) {
825 proto_byte = ProtoWord & 0xff;
827 proto_word_offset = 0;
828 while (ProtoWord != 0 || proto_byte != 0) {
829 while (proto_byte == 0) {
830 proto_byte = ProtoWord & 0xff;
832 proto_word_offset += 8;
834 proto_offset = offset_table[proto_byte] + proto_word_offset;
835 proto_byte = next_table[proto_byte];
836 Proto = &(ProtoSet->
Protos[ProtoNum + proto_offset]);
837 ConfigWord = Proto->
Configs[0];
838 A3 = (((Proto->
A * (Feature->
X - 128)) << 1)
839 - (Proto->
B * (Feature->
Y - 128)) + (Proto->
C << 9));
847 A3 >>= mult_trunc_shift_bits_;
848 M3 >>= mult_trunc_shift_bits_;
849 if (static_cast<uint32_t>(A3) > evidence_mult_mask_)
850 A3 = evidence_mult_mask_;
851 if (static_cast<uint32_t>(M3) > evidence_mult_mask_)
852 M3 = evidence_mult_mask_;
854 A4 = (A3 * A3) + (M3 * M3);
855 A4 >>= table_trunc_shift_bits_;
856 if (A4 > evidence_table_mask_)
859 Evidence = similarity_evidence_table_[A4];
863 ActualProtoNum + proto_offset,
864 Evidence, ConfigMask, ConfigWord);
866 ConfigWord &= *ConfigMask;
870 while (ConfigWord != 0 || config_byte != 0) {
871 while (config_byte == 0) {
872 config_byte = ConfigWord & 0xff;
876 config_offset = offset_table[config_byte];
877 config_byte = next_table[config_byte];
878 if (Evidence > UINT8Pointer[config_offset])
879 UINT8Pointer[config_offset] = Evidence;
885 ClassTemplate->
ProtoLengths[ActualProtoNum + proto_offset];
886 ProtoIndex > 0; ProtoIndex--, UINT8Pointer++) {
887 if (Evidence > *UINT8Pointer) {
888 Temp = *UINT8Pointer;
889 *UINT8Pointer = Evidence;
892 else if (Evidence == 0)
907 int SumOverConfigs = 0;
908 for (ConfigNum = ClassTemplate->
NumConfigs; ConfigNum > 0; ConfigNum--) {
909 int evidence = *UINT8Pointer++;
910 SumOverConfigs += evidence;
911 *IntPointer++ += evidence;
913 return SumOverConfigs;
922 #ifndef GRAPHICS_DISABLED 923 void IntegerMatcher::DebugFeatureProtoError(
940 cprintf(
"Configuration Mask:\n");
941 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++)
942 cprintf(
"%1d", (((*ConfigMask) >> ConfigNum) & 1));
945 cprintf(
"Feature Error for Configurations:\n");
946 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++) {
951 / NumFeatures / 256.0));
958 for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->
NumProtoSets;
961 for (ProtoWordNum = 0; ProtoWordNum < 2;
962 ProtoWordNum++, ProtoMask++) {
965 ((ProtoNum < (PROTOS_PER_PROTO_SET >> 1))
966 && (ActualProtoNum < ClassTemplate->
NumProtos));
967 ProtoNum++, ActualProtoNum++)
968 cprintf (
"%1d", (((*ProtoMask) >> ProtoNum) & 1));
975 for (
int i = 0; i < ClassTemplate->
NumConfigs; i++)
980 for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->
NumProtoSets;
982 ProtoSet = ClassTemplate->
ProtoSets[ProtoSetIndex];
986 (ActualProtoNum < ClassTemplate->NumProtos));
987 ProtoNum++, ActualProtoNum++) {
988 cprintf (
"P %3d =", ActualProtoNum);
990 for (
int j = 0; j < ClassTemplate->
ProtoLengths[ActualProtoNum]; j++) {
997 temp / 256.0 / ClassTemplate->
ProtoLengths[ActualProtoNum]);
1001 while (ConfigWord) {
1002 cprintf (
"%5d", ConfigWord & 1 ? temp : 0);
1004 ProtoConfigs[ConfigNum] += temp;
1014 cprintf (
"Proto Error for Configurations:\n");
1015 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++)
1018 ProtoConfigs[ConfigNum] /
1024 cprintf (
"Proto Sum for Configurations:\n");
1025 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++)
1026 cprintf (
" %4.1f", ProtoConfigs[ConfigNum] / 256.0);
1029 cprintf (
"Proto Length for Configurations:\n");
1030 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++)
1038 void IntegerMatcher::DisplayProtoDebugInfo(
1043 bool SeparateDebugWindows) {
1050 if (SeparateDebugWindows) {
1056 for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->
NumProtoSets;
1058 ProtoSet = ClassTemplate->
ProtoSets[ProtoSetIndex];
1062 (ActualProtoNum < ClassTemplate->NumProtos));
1063 ProtoNum++, ActualProtoNum++) {
1066 for (
int i = 0; i < ClassTemplate->
ProtoLengths[ActualProtoNum]; i++)
1071 if ((ProtoSet->
Protos[ProtoNum]).Configs[0] & (*ConfigMask)) {
1079 void IntegerMatcher::DisplayFeatureDebugInfo(
1085 int AdaptFeatureThreshold,
1087 bool SeparateDebugWindows) {
1090 tables->
Clear(ClassTemplate);
1093 if (SeparateDebugWindows) {
1098 for (
int Feature = 0; Feature < NumFeatures; Feature++) {
1099 UpdateTablesForFeature(
1100 ClassTemplate, ProtoMask, ConfigMask, Feature, &Features[Feature],
1105 for (
int i = 0; i < ClassTemplate->
NumConfigs; i++)
1111 if (best < AdaptFeatureThreshold)
1140 for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->
NumProtoSets;
1142 ProtoSet = ClassTemplate->
ProtoSets[ProtoSetIndex];
1146 ProtoNum++, ActualProtoNum++) {
1148 for (
int i = 0; i < ClassTemplate->
ProtoLengths[ActualProtoNum]; i++)
1149 temp += proto_evidence_[ActualProtoNum] [i];
1152 ConfigWord &= *ConfigMask;
1153 IntPointer = sum_feature_evidence_;
1154 while (ConfigWord) {
1156 *IntPointer += temp;
1171 for (
int i = 0; i < ClassTemplate->
NumConfigs; i++) {
1172 sum_feature_evidence_[i] = (sum_feature_evidence_[i] << 8) /
1184 int IntegerMatcher::FindBestMatch(
1190 result->
fonts.truncate(0);
1194 for (
int c = 0; c < class_template->
NumConfigs; ++c) {
1196 if (*classify_debug_level_ > 2)
1197 tprintf(
"Config %d, rating=%d\n", c, rating);
1198 if (rating > best_match) {
1200 best_match = rating;
1206 result->
rating = best_match / 65536.0f;
1216 int normalization_factor,
1217 int matcher_multiplier) {
1218 return (rating * blob_length +
1219 matcher_multiplier * normalization_factor / 256.0) /
1220 (blob_length + matcher_multiplier);
1235 HeapSort (
int n,
register int ra[],
register int rb[]) {
1260 if (j < ir && ra[j] < ra[j + 1])
#define DisplayProtoMatchesOn(D)
#define ClipMatchEvidenceOn(D)
#define NUM_BITS_PER_CLASS
int SetupResults(GenericVector< CP_RESULT_STRUCT > *results) const
void SummarizeResult(const Classify &classify, const INT_TEMPLATES_STRUCT *int_templates, const uinT16 *expected_num_features, int norm_multiplier, const uinT8 *normalization_factors) const
void InitFeatureDisplayWindowIfReqd()
#define PrintMatchSummaryOn(D)
uinT8 feature_evidence_[MAX_NUM_CONFIGS]
void DisplayIntProto(INT_CLASS Class, PROTO_ID ProtoId, FLOAT32 Evidence)
float ApplyCNCorrection(float rating, int blob_length, int normalization_factor, int matcher_multiplier)
void IMDebugConfigurationSum(int FeatureNum, uinT8 *FeatureEvidence, inT32 ConfigCount)
CLASS_PRUNER_STRUCT * ClassPruners[MAX_NUM_CLASS_PRUNERS]
void ComputeScores(const INT_TEMPLATES_STRUCT *int_templates, int num_features, const INT_FEATURE_STRUCT *features)
void IMDebugConfiguration(int FeatureNum, uinT16 ActualProtoNum, uinT8 Evidence, BIT_VECTOR ConfigMask, uinT32 ConfigWord)
void Clear(const INT_CLASS class_template)
PROTO_SET ProtoSets[MAX_NUM_PROTO_SETS]
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
GenericVector< ScoredFont > fonts
#define PROTOS_PER_PROTO_SET
uinT8 proto_evidence_[MAX_NUM_PROTOS][MAX_PROTO_INDEX]
void AdjustForExpectedNumFeatures(const uinT16 *expected_num_features, int cutoff_strength)
INT_FEATURE_STRUCT INT_FEATURE_ARRAY[MAX_NUM_INT_FEATURES]
ClassPruner(int max_classes)
#define MatchDebuggingOn(D)
int PruneClasses(const INT_TEMPLATES_STRUCT *int_templates, int num_features, int keep_this, const INT_FEATURE_STRUCT *features, const uinT8 *normalization_factors, const uinT16 *expected_num_features, GenericVector< CP_RESULT_STRUCT > *results)
bool get_enabled(UNICHAR_ID unichar_id) const
uinT32 p[NUM_CP_BUCKETS][NUM_CP_BUCKETS][NUM_CP_BUCKETS][WERDS_PER_CP_VECTOR]
const CHAR_FRAGMENT * get_fragment(UNICHAR_ID unichar_id) const
STRING ClassIDToDebugStr(const INT_TEMPLATES_STRUCT *templates, int class_id, int config_id) const
#define INTMATCHER_OFFSET_TABLE_SIZE
#define WERDS_PER_CP_VECTOR
void Match(INT_CLASS ClassTemplate, BIT_VECTOR ProtoMask, BIT_VECTOR ConfigMask, inT16 NumFeatures, const INT_FEATURE_STRUCT *Features, tesseract::UnicharRating *Result, int AdaptFeatureThreshold, int Debug, bool SeparateDebugWindows)
bool disable_character_fragments
void ClearFeatureEvidence(const INT_CLASS class_template)
int sum_feature_evidence_[MAX_NUM_CONFIGS]
const char * string() const
void DisplayIntFeature(const INT_FEATURE_STRUCT *Feature, FLOAT32 Evidence)
void UpdateSumOfProtoEvidences(INT_CLASS ClassTemplate, BIT_VECTOR ConfigMask, inT16 NumFeatures)
uinT16 ConfigLengths[MAX_NUM_CONFIGS]
void InitIntMatchWindowIfReqd()
INT_PROTO_STRUCT Protos[PROTOS_PER_PROTO_SET]
uinT32 Configs[WERDS_PER_CONFIG_VEC]
#define PrintProtoMatchesOn(D)
void cprintf(const char *format,...)
void NormalizeForXheight(int norm_multiplier, const uinT8 *normalization_factors)
#define offset_table_entries
void HeapSort(int n, register int ra[], register int rb[])
void DebugMatch(const Classify &classify, const INT_TEMPLATES_STRUCT *int_templates, const INT_FEATURE_STRUCT *features) const
#define next_table_entries
void DisableDisabledClasses(const UNICHARSET &unicharset)
#define DisplayFeatureMatchesOn(D)
#define PrintFeatureMatchesOn(D)
void DisableFragments(const UNICHARSET &unicharset)
static const float kSimilarityCenter
void InitProtoDisplayWindowIfReqd()
void PruneAndSort(int pruning_factor, int keep_this, bool max_of_non_fragments, const UNICHARSET &unicharset)
int FindGoodProtos(INT_CLASS ClassTemplate, BIT_VECTOR ProtoMask, BIT_VECTOR ConfigMask, uinT16 BlobLength, inT16 NumFeatures, INT_FEATURE_ARRAY Features, PROTO_ID *ProtoArray, int AdaptProtoThreshold, int Debug)
void init_to_size(int size, T t)
int FindBadFeatures(INT_CLASS ClassTemplate, BIT_VECTOR ProtoMask, BIT_VECTOR ConfigMask, uinT16 BlobLength, inT16 NumFeatures, INT_FEATURE_ARRAY Features, FEATURE_ID *FeatureArray, int AdaptFeatureThreshold, int Debug)
int RoundUp(int n, int block_size)
void Init(tesseract::IntParam *classify_debug_level)
void NormalizeSums(INT_CLASS ClassTemplate, inT16 NumFeatures, inT32 used_features)
static const float kSEExponentialMultiplier
#define CLASS_PRUNER_CLASS_MASK