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_);
303 int max_num_classes = int_templates->
NumClasses;
304 for (
int f = 0; f < num_features_; ++f) {
306 tprintf(
"F=%3d(%d,%d,%d),", f, feature->
X, feature->
Y, feature->
Theta);
312 for (
int pruner_set = 0; pruner_set < num_pruners; ++pruner_set) {
315 const uinT32* pruner_word_ptr =
318 uinT32 pruner_word = *pruner_word_ptr++;
319 for (
int word_class = 0; word_class < 16 &&
320 class_id < max_num_classes; ++word_class, ++class_id) {
321 if (norm_count_[class_id] >= pruning_threshold_) {
338 const uinT16* expected_num_features,
340 const uinT8* normalization_factors)
const {
341 tprintf(
"CP:%d classes, %d features:\n", num_classes_, num_features_);
342 for (
int i = 0; i < num_classes_; ++i) {
343 int class_id = sort_index_[num_classes_ - i];
346 tprintf(
"%s:Initial=%d, E=%d, Xht-adj=%d, N=%d, Rat=%.2f\n",
348 class_count_[class_id],
349 expected_num_features[class_id],
350 (norm_multiplier * normalization_factors[class_id]) >> 8,
351 sort_key_[num_classes_ - i],
352 100.0 - 100.0 * sort_key_[num_classes_ - i] /
362 for (
int c = 0; c < num_classes_; ++c) {
363 (*results)[c].Class = sort_index_[num_classes_ - c];
364 (*results)[c].Rating = 1.0 - sort_key_[num_classes_ - c] /
383 int rounded_classes_;
385 int pruning_threshold_;
408 int num_features,
int keep_this,
410 const uinT8* normalization_factors,
411 const uinT16* expected_num_features,
427 classify_cp_cutoff_strength);
429 if (shape_table_ ==
NULL)
436 if (normalization_factors !=
NULL) {
438 normalization_factors);
443 pruner.
PruneAndSort(classify_class_pruner_threshold, keep_this,
444 shape_table_ ==
NULL, unicharset);
446 if (classify_debug_level > 2) {
447 pruner.
DebugMatch(*
this, int_templates, features);
449 if (classify_debug_level > 1) {
451 classify_class_pruner_multiplier,
452 normalization_factors);
467 int AdaptFeatureThreshold,
469 bool SeparateDebugWindows) {
497 cprintf (
"Integer Matcher -------------------------------------------\n");
499 tables->
Clear(ClassTemplate);
502 for (Feature = 0; Feature < NumFeatures; Feature++) {
503 int csum = UpdateTablesForFeature(ClassTemplate, ProtoMask, ConfigMask,
504 Feature, &Features[Feature],
511 #ifndef GRAPHICS_DISABLED 513 DebugFeatureProtoError(ClassTemplate, ProtoMask, ConfigMask, *tables,
518 DisplayProtoDebugInfo(ClassTemplate, ProtoMask, ConfigMask,
519 *tables, SeparateDebugWindows);
523 DisplayFeatureDebugInfo(ClassTemplate, ProtoMask, ConfigMask, NumFeatures,
524 Features, AdaptFeatureThreshold, Debug,
525 SeparateDebugWindows);
530 tables->
NormalizeSums(ClassTemplate, NumFeatures, NumFeatures);
532 BestMatch = FindBestMatch(ClassTemplate, *tables, Result);
534 #ifndef GRAPHICS_DISABLED 539 cprintf(
"Match Complete --------------------------------------------\n");
555 int AdaptProtoThreshold,
580 int NumGoodProtos = 0;
585 (
"Find Good Protos -------------------------------------------\n");
587 tables->
Clear(ClassTemplate);
589 for (
int Feature = 0; Feature < NumFeatures; Feature++)
590 UpdateTablesForFeature(
591 ClassTemplate, ProtoMask, ConfigMask, Feature, &(Features[Feature]),
594 #ifndef GRAPHICS_DISABLED 596 DebugFeatureProtoError(ClassTemplate, ProtoMask, ConfigMask, *tables,
601 for (
int proto = 0; proto < ClassTemplate->
NumProtos; proto++) {
604 for (
int i = 0; i < ClassTemplate->
ProtoLengths[proto]; i++)
610 if (Temp >= AdaptProtoThreshold) {
618 cprintf (
"Match Complete --------------------------------------------\n");
621 return NumGoodProtos;
634 int AdaptFeatureThreshold,
655 int NumBadFeatures = 0;
659 cprintf(
"Find Bad Features -------------------------------------------\n");
661 tables->
Clear(ClassTemplate);
663 for (
int Feature = 0; Feature < NumFeatures; Feature++) {
664 UpdateTablesForFeature(
665 ClassTemplate, ProtoMask, ConfigMask, Feature, &Features[Feature],
670 for (
int i = 0; i < ClassTemplate->
NumConfigs; i++)
675 if (best < AdaptFeatureThreshold) {
676 *FeatureArray = Feature;
682 #ifndef GRAPHICS_DISABLED 684 DebugFeatureProtoError(ClassTemplate, ProtoMask, ConfigMask, *tables,
689 cprintf(
"Match Complete --------------------------------------------\n");
692 return NumBadFeatures;
698 classify_debug_level_ = classify_debug_level;
703 double Similarity = ((double) IntSimilarity) / 65536.0 / 65536.0;
704 double evidence = Similarity / kSimilarityCenter;
705 evidence = 255.0 / (evidence * evidence + 1.0);
707 if (kSEExponentialMultiplier > 0.0) {
708 double scale = 1.0 - exp(-kSEExponentialMultiplier) *
709 exp(kSEExponentialMultiplier * ((
double) i / SE_TABLE_SIZE));
713 similarity_evidence_table_[i] = (
uinT8) (evidence + 0.5);
717 evidence_table_mask_ =
718 ((1 << kEvidenceTableBits) - 1) << (9 - kEvidenceTableBits);
719 mult_trunc_shift_bits_ = (14 - kIntEvidenceTruncBits);
720 table_trunc_shift_bits_ = (27 -
SE_TABLE_BITS - (mult_trunc_shift_bits_ << 1));
721 evidence_mult_mask_ = ((1 << kIntEvidenceTruncBits) - 1);
729 memset(sum_feature_evidence_, 0,
730 class_template->
NumConfigs *
sizeof(sum_feature_evidence_[0]));
731 memset(proto_evidence_, 0,
732 class_template->
NumProtos *
sizeof(proto_evidence_[0]));
736 memset(feature_evidence_, 0,
737 class_template->
NumConfigs *
sizeof(feature_evidence_[0]));
757 cprintf (
"F = %3d, P = %3d, E = %3d, Configs = ",
758 FeatureNum, (
int) ActualProtoNum, (
int) Evidence);
772 uinT8 *FeatureEvidence,
783 cprintf(
"F=%3d, C=", FeatureNum);
784 for (
int ConfigNum = 0; ConfigNum < ConfigCount; ConfigNum++) {
785 cprintf(
"%4d", FeatureEvidence[ConfigNum]);
793 int IntegerMatcher::UpdateTablesForFeature(
814 register uinT32 ConfigWord;
815 register uinT32 ProtoWord;
817 register uinT32 ActualProtoNum;
819 inT32 proto_word_offset;
830 uinT32 ThetaFeatureAddress;
831 register uinT8 *UINT8Pointer;
832 register int ProtoIndex;
834 register int *IntPointer;
843 XFeatureAddress = ((Feature->
X >> 2) << 1);
847 for (ProtoSetIndex = 0, ActualProtoNum = 0;
848 ProtoSetIndex < ClassTemplate->
NumProtoSets; ProtoSetIndex++) {
849 ProtoSet = ClassTemplate->
ProtoSets[ProtoSetIndex];
850 ProtoPrunerPtr = (
uinT32 *) ((*ProtoSet).ProtoPruner);
852 ProtoNum += (PROTOS_PER_PROTO_SET >> 1), ActualProtoNum +=
853 (PROTOS_PER_PROTO_SET >> 1), ProtoMask++, ProtoPrunerPtr++) {
855 ProtoWord = *(ProtoPrunerPtr + XFeatureAddress);
856 ProtoWord &= *(ProtoPrunerPtr + YFeatureAddress);
857 ProtoWord &= *(ProtoPrunerPtr + ThetaFeatureAddress);
858 ProtoWord &= *ProtoMask;
860 if (ProtoWord != 0) {
861 proto_byte = ProtoWord & 0xff;
863 proto_word_offset = 0;
864 while (ProtoWord != 0 || proto_byte != 0) {
865 while (proto_byte == 0) {
866 proto_byte = ProtoWord & 0xff;
868 proto_word_offset += 8;
870 proto_offset = offset_table[proto_byte] + proto_word_offset;
871 proto_byte = next_table[proto_byte];
872 Proto = &(ProtoSet->
Protos[ProtoNum + proto_offset]);
873 ConfigWord = Proto->
Configs[0];
874 A3 = (((Proto->
A * (Feature->
X - 128)) << 1)
875 - (Proto->
B * (Feature->
Y - 128)) + (Proto->
C << 9));
883 A3 >>= mult_trunc_shift_bits_;
884 M3 >>= mult_trunc_shift_bits_;
885 if (A3 > evidence_mult_mask_)
886 A3 = evidence_mult_mask_;
887 if (M3 > evidence_mult_mask_)
888 M3 = evidence_mult_mask_;
890 A4 = (A3 * A3) + (M3 * M3);
891 A4 >>= table_trunc_shift_bits_;
892 if (A4 > evidence_table_mask_)
895 Evidence = similarity_evidence_table_[A4];
899 ActualProtoNum + proto_offset,
900 Evidence, ConfigMask, ConfigWord);
902 ConfigWord &= *ConfigMask;
906 while (ConfigWord != 0 || config_byte != 0) {
907 while (config_byte == 0) {
908 config_byte = ConfigWord & 0xff;
912 config_offset = offset_table[config_byte];
913 config_byte = next_table[config_byte];
914 if (Evidence > UINT8Pointer[config_offset])
915 UINT8Pointer[config_offset] = Evidence;
921 ClassTemplate->
ProtoLengths[ActualProtoNum + proto_offset];
922 ProtoIndex > 0; ProtoIndex--, UINT8Pointer++) {
923 if (Evidence > *UINT8Pointer) {
924 Temp = *UINT8Pointer;
925 *UINT8Pointer = Evidence;
928 else if (Evidence == 0)
943 int SumOverConfigs = 0;
944 for (ConfigNum = ClassTemplate->
NumConfigs; ConfigNum > 0; ConfigNum--) {
945 int evidence = *UINT8Pointer++;
946 SumOverConfigs += evidence;
947 *IntPointer++ += evidence;
949 return SumOverConfigs;
954 #ifndef GRAPHICS_DISABLED 955 void IntegerMatcher::DebugFeatureProtoError(
981 cprintf(
"Configuration Mask:\n");
982 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++)
983 cprintf(
"%1d", (((*ConfigMask) >> ConfigNum) & 1));
986 cprintf(
"Feature Error for Configurations:\n");
987 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++) {
992 / NumFeatures / 256.0));
999 for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->
NumProtoSets;
1002 for (ProtoWordNum = 0; ProtoWordNum < 2;
1003 ProtoWordNum++, ProtoMask++) {
1006 ((ProtoNum < (PROTOS_PER_PROTO_SET >> 1))
1007 && (ActualProtoNum < ClassTemplate->
NumProtos));
1008 ProtoNum++, ActualProtoNum++)
1009 cprintf (
"%1d", (((*ProtoMask) >> ProtoNum) & 1));
1016 for (
int i = 0; i < ClassTemplate->
NumConfigs; i++)
1017 ProtoConfigs[i] = 0;
1020 cprintf (
"Proto Evidence:\n");
1021 for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->
NumProtoSets;
1023 ProtoSet = ClassTemplate->
ProtoSets[ProtoSetIndex];
1027 (ActualProtoNum < ClassTemplate->NumProtos));
1028 ProtoNum++, ActualProtoNum++) {
1029 cprintf (
"P %3d =", ActualProtoNum);
1031 for (
int j = 0; j < ClassTemplate->
ProtoLengths[ActualProtoNum]; j++) {
1038 temp / 256.0 / ClassTemplate->
ProtoLengths[ActualProtoNum]);
1042 while (ConfigWord) {
1043 cprintf (
"%5d", ConfigWord & 1 ? temp : 0);
1045 ProtoConfigs[ConfigNum] += temp;
1055 cprintf (
"Proto Error for Configurations:\n");
1056 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++)
1059 ProtoConfigs[ConfigNum] /
1065 cprintf (
"Proto Sum for Configurations:\n");
1066 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++)
1067 cprintf (
" %4.1f", ProtoConfigs[ConfigNum] / 256.0);
1070 cprintf (
"Proto Length for Configurations:\n");
1071 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++)
1081 void IntegerMatcher::DisplayProtoDebugInfo(
1086 bool SeparateDebugWindows) {
1093 if (SeparateDebugWindows) {
1099 for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->
NumProtoSets;
1101 ProtoSet = ClassTemplate->
ProtoSets[ProtoSetIndex];
1105 (ActualProtoNum < ClassTemplate->NumProtos));
1106 ProtoNum++, ActualProtoNum++) {
1109 for (
int i = 0; i < ClassTemplate->
ProtoLengths[ActualProtoNum]; i++)
1114 if ((ProtoSet->
Protos[ProtoNum]).Configs[0] & (*ConfigMask)) {
1123 void IntegerMatcher::DisplayFeatureDebugInfo(
1129 int AdaptFeatureThreshold,
1131 bool SeparateDebugWindows) {
1134 tables->
Clear(ClassTemplate);
1137 if (SeparateDebugWindows) {
1142 for (
int Feature = 0; Feature < NumFeatures; Feature++) {
1143 UpdateTablesForFeature(
1144 ClassTemplate, ProtoMask, ConfigMask, Feature, &Features[Feature],
1149 for (
int i = 0; i < ClassTemplate->
NumConfigs; i++)
1155 if (best < AdaptFeatureThreshold)
1183 for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->
NumProtoSets;
1185 ProtoSet = ClassTemplate->
ProtoSets[ProtoSetIndex];
1189 ProtoNum++, ActualProtoNum++) {
1191 for (
int i = 0; i < ClassTemplate->
ProtoLengths[ActualProtoNum]; i++)
1192 temp += proto_evidence_[ActualProtoNum] [i];
1195 ConfigWord &= *ConfigMask;
1196 IntPointer = sum_feature_evidence_;
1197 while (ConfigWord) {
1199 *IntPointer += temp;
1215 for (
int i = 0; i < ClassTemplate->
NumConfigs; i++) {
1216 sum_feature_evidence_[i] = (sum_feature_evidence_[i] << 8) /
1223 int IntegerMatcher::FindBestMatch(
1240 result->
fonts.truncate(0);
1244 for (
int c = 0; c < class_template->
NumConfigs; ++c) {
1246 if (*classify_debug_level_ > 2)
1247 tprintf(
"Config %d, rating=%d\n", c, rating);
1248 if (rating > best_match) {
1250 best_match = rating;
1256 result->
rating = best_match / 65536.0f;
1264 int normalization_factor,
1265 int matcher_multiplier) {
1266 return (rating * blob_length +
1267 matcher_multiplier * normalization_factor / 256.0) /
1268 (blob_length + matcher_multiplier);
1273 HeapSort (
int n,
register int ra[],
register int rb[]) {
1288 register int i, rra, rrb;
1312 if (j < ir && ra[j] < ra[j + 1])
uinT32 Configs[WERDS_PER_CONFIG_VEC]
#define DisplayProtoMatchesOn(D)
void DisableFragments(const UNICHARSET &unicharset)
#define offset_table_entries
INT_PROTO_STRUCT Protos[PROTOS_PER_PROTO_SET]
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)
void DebugMatch(const Classify &classify, const INT_TEMPLATES_STRUCT *int_templates, const INT_FEATURE_STRUCT *features) const
uinT8 proto_evidence_[MAX_NUM_PROTOS][MAX_PROTO_INDEX]
void Clear(const INT_CLASS class_template)
#define PrintFeatureMatchesOn(D)
#define PrintMatchSummaryOn(D)
void IMDebugConfigurationSum(int FeatureNum, uinT8 *FeatureEvidence, inT32 ConfigCount)
uinT32 p[NUM_CP_BUCKETS][NUM_CP_BUCKETS][NUM_CP_BUCKETS][WERDS_PER_CP_VECTOR]
STRING ClassIDToDebugStr(const INT_TEMPLATES_STRUCT *templates, int class_id, int config_id) const
#define INTMATCHER_OFFSET_TABLE_SIZE
#define ClipMatchEvidenceOn(D)
void ClearFeatureEvidence(const INT_CLASS class_template)
static const float kSimilarityCenter
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(tesseract::IntParam *classify_debug_level)
bool disable_character_fragments
GenericVector< ScoredFont > fonts
void NormalizeSums(INT_CLASS ClassTemplate, inT16 NumFeatures, inT32 used_features)
PROTO_SET ProtoSets[MAX_NUM_PROTO_SETS]
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)
void DisplayIntFeature(const INT_FEATURE_STRUCT *Feature, FLOAT32 Evidence)
#define MatchDebuggingOn(D)
const char * string() const
INT_FEATURE_STRUCT INT_FEATURE_ARRAY[MAX_NUM_INT_FEATURES]
ClassPruner(int max_classes)
void UpdateSumOfProtoEvidences(INT_CLASS ClassTemplate, BIT_VECTOR ConfigMask, inT16 NumFeatures)
#define DisplayFeatureMatchesOn(D)
uinT16 ConfigLengths[MAX_NUM_CONFIGS]
int SetupResults(GenericVector< CP_RESULT_STRUCT > *results) const
void init_to_size(int size, T t)
#define WERDS_PER_CP_VECTOR
uinT8 feature_evidence_[MAX_NUM_CONFIGS]
void NormalizeForXheight(int norm_multiplier, const uinT8 *normalization_factors)
void DisableDisabledClasses(const UNICHARSET &unicharset)
float ApplyCNCorrection(float rating, int blob_length, int normalization_factor, int matcher_multiplier)
const CHAR_FRAGMENT * get_fragment(UNICHAR_ID unichar_id) const
void cprintf(const char *format,...)
void DisplayIntProto(INT_CLASS Class, PROTO_ID ProtoId, FLOAT32 Evidence)
void InitProtoDisplayWindowIfReqd()
void AdjustForExpectedNumFeatures(const uinT16 *expected_num_features, int cutoff_strength)
void ComputeScores(const INT_TEMPLATES_STRUCT *int_templates, int num_features, const INT_FEATURE_STRUCT *features)
bool get_enabled(UNICHAR_ID unichar_id) const
#define PrintProtoMatchesOn(D)
void InitIntMatchWindowIfReqd()
void InitFeatureDisplayWindowIfReqd()
#define PROTOS_PER_PROTO_SET
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)
CLASS_PRUNER_STRUCT * ClassPruners[MAX_NUM_CLASS_PRUNERS]
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
#define NUM_BITS_PER_CLASS
#define next_table_entries
void PruneAndSort(int pruning_factor, int keep_this, bool max_of_non_fragments, const UNICHARSET &unicharset)
void HeapSort(int n, register int ra[], register int rb[])
#define CLASS_PRUNER_CLASS_MASK
int sum_feature_evidence_[MAX_NUM_CONFIGS]
static const float kSEExponentialMultiplier
void IMDebugConfiguration(int FeatureNum, uinT16 ActualProtoNum, uinT8 Evidence, BIT_VECTOR ConfigMask, uinT32 ConfigWord)
void SummarizeResult(const Classify &classify, const INT_TEMPLATES_STRUCT *int_templates, const uinT16 *expected_num_features, int norm_multiplier, const uinT8 *normalization_factors) const
int RoundUp(int n, int block_size)