⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intmatcher.cpp

📁 一OCR的相关资料。.希望对研究OCR的朋友有所帮助.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/****************************************************************************** **      Filename:    intmatcher.c **      Purpose:     Generic high level classification routines. **      Author:      Robert Moss **      History:     Wed Feb 13 17:35:28 MST 1991, RWM, Created. **                   Mon Mar 11 16:33:02 MST 1991, RWM, Modified to add **                        support for adaptive matching. **      (c) Copyright Hewlett-Packard Company, 1988. ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** http://www.apache.org/licenses/LICENSE-2.0 ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. ******************************************************************************//**----------------------------------------------------------------------------                          Include Files and Type Defines----------------------------------------------------------------------------**/#include "intmatcher.h"#include "tordvars.h"#include "callcpp.h"#include <math.h>#define CLASS_MASK_SIZE ((MAX_NUM_CLASSES*NUM_BITS_PER_CLASS \		+BITS_PER_WERD-1)/BITS_PER_WERD)/**----------------------------------------------------------------------------                    Global Data Definitions and Declarations----------------------------------------------------------------------------**/#define  SE_TABLE_BITS    9#define  SE_TABLE_SIZE  512#define TEMPLATE_CACHE 2static UINT8 SimilarityEvidenceTable[SE_TABLE_SIZE];static UINT8 offset_table[256] = {  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, 0, 1, 0, 2, 0, 1, 0,  5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,  4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,  6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1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x5c, 0x5e,  0x40, 0x60, 0x60, 0x62, 0x60, 0x64, 0x64, 0x66, 0x60, 0x68, 0x68, 0x6a,  0x68, 0x6c, 0x6c, 0x6e,  0x60, 0x70, 0x70, 0x72, 0x70, 0x74, 0x74, 0x76, 0x70, 0x78, 0x78, 0x7a,  0x78, 0x7c, 0x7c, 0x7e,  0, 0x80, 0x80, 0x82, 0x80, 0x84, 0x84, 0x86, 0x80, 0x88, 0x88, 0x8a, 0x88,  0x8c, 0x8c, 0x8e,  0x80, 0x90, 0x90, 0x92, 0x90, 0x94, 0x94, 0x96, 0x90, 0x98, 0x98, 0x9a,  0x98, 0x9c, 0x9c, 0x9e,  0x80, 0xa0, 0xa0, 0xa2, 0xa0, 0xa4, 0xa4, 0xa6, 0xa0, 0xa8, 0xa8, 0xaa,  0xa8, 0xac, 0xac, 0xae,  0xa0, 0xb0, 0xb0, 0xb2, 0xb0, 0xb4, 0xb4, 0xb6, 0xb0, 0xb8, 0xb8, 0xba,  0xb8, 0xbc, 0xbc, 0xbe,  0x80, 0xc0, 0xc0, 0xc2, 0xc0, 0xc4, 0xc4, 0xc6, 0xc0, 0xc8, 0xc8, 0xca,  0xc8, 0xcc, 0xcc, 0xce,  0xc0, 0xd0, 0xd0, 0xd2, 0xd0, 0xd4, 0xd4, 0xd6, 0xd0, 0xd8, 0xd8, 0xda,  0xd8, 0xdc, 0xdc, 0xde,  0xc0, 0xe0, 0xe0, 0xe2, 0xe0, 0xe4, 0xe4, 0xe6, 0xe0, 0xe8, 0xe8, 0xea,  0xe8, 0xec, 0xec, 0xee,  0xe0, 0xf0, 0xf0, 0xf2, 0xf0, 0xf4, 0xf4, 0xf6, 0xf0, 0xf8, 0xf8, 0xfa,  0xf8, 0xfc, 0xfc, 0xfe};static int cp_maxes[128] = {  100,  100, 100, 100, 100, 100, 100, 100, 100,  100, 100, 100, 100, 100, 100, 100, 100,  100, 100, 100, 100, 100, 100, 100, 100,  100, 100, 100, 100, 100, 100, 100, 100,  194,                           //!  100,                           //"  182,                           //#  224,                           //$  203,                           //%  242,                           //&  245,                           //'  226,                           //(  190,                           //)  244,                           //*  195,                           //+  254,                           //,  253,                           //-  253,                           //.  206,                           ///  253,                           //0  234,                           //1  252,                           //2  246,                           //3  253,                           //4  160,                           //5  202,                           //6  199,                           //7  171,                           //8  227,                           //9  208,                           //:  188,                           //;  60,                            //<  221,                           //=  138,                           //>  108,                           //?  98,                            //@  251,                           //A  214,                           //B  230,                           //C  252,                           //D  237,                           //E  217,                           //F  233,                           //G  174,                           //H  216,                           //I  210,                           //J  252,                           //K  253,                           //L  233,                           //M  243,                           //N  240,                           //O  230,                           //P  167,                           //Q  248,                           //R  250,                           //S  232,                           //T  209,                           //U  193,                           //V  254,                           //W  146,                           //X  198,                           //Y  107,                           //Z  167,                           //[  163,                           //  73,                            //]  16,                            //^  199,                           //_  162,                           //`  251,                           //a  250,                           //b  254,                           //c  253,                           //d  252,                           //e  253,                           //f  248,                           //g  251,                           //h  254,                           //i  201,                           //j  224,                           //k  253,                           //l  242,                           //m  254,                           //n  254,                           //o  253,                           //p  246,                           //q  254,                           //r  254,                           //s  254,                           //t  245,                           //u  221,                           //v  230,                           //w  251,                           //x  243,                           //y  133,                           //z  35,                            //{  100,                           //|  143,                           //}  100,                           //~  100};static float cp_ratios[128] = {  1.5f,  1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f,  1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f,  1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f,  1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f, 1.5f,  2.24775,                       //!  1.5,                           //"  1.90376,                       //#  1.61443,                       //$  1.87857,                       //%  2.29167,                       //&  7.4,                           //'  4.7,                           //(  9.4,                           //)  2.13014,                       //*  1.53175,                       //+  2.86957,                       //,  7.4,                           //-  7.4,                           //.  9.4,                           ///  8.1,                           //0  12.6,                          //1  2.7439,                        //2  4.22222,                       //3  2.57447,                       //4  2.93902,                       //5  4.23684,                       //6  6,                             //7  2.78889,                       //8  3.55,                          //9  8.5,                           //:  2.4,                           //;  1.5,                           //<  1.94737,                       //=  1.89394,                       //>  1.5,                           //?  1.5,                           //@  3.125,                         //A  5.5,                           //B  6.1,                           //C  6,                             //D  2.78205,                       //E  2.03763,                       //F  2.73256,                       //G  2.57692,                       //H  11.8,                          //I  7.1,                           //J  1.85227,                       //K  7.4,                           //L  2.26056,                       //M  2.46078,                       //N  6.85714,                       //O  3.45238,                       //P  2.47222,                       //Q  3.74,                          //R  10.2,                          //S  3.08065,                       //T  6.1,                           //U  9.5,                           //V  7.1,                           //W  7.9,                           //X  2.55714,                       //Y  7.7,                           //Z  2,                             //[  1.5,                           //  2.55714,                       //]  1.5,                           //^  1.80065,                       //_  1.69512,                       //`  5.34,                          //a  7.3,                           //b  6.43333,                       //c  4.10606,                       //d  4.41667,                       //e  12.6,                          //f  3.7093,                        //g  2.38889,                       //h  5.5,                           //i  4.03125,                       //j  2.24561,                       //k  11.5,                          //l  3.5,                           //m  5.63333,                       //n  11,                            //o  2.52667,                       //p  2.1129,                        //q  6.56667,                       //r  6.42857,                       //s  11.4,                          //t  3.62,                          //u  2.77273,                       //v  2.90909,                       //w  6.5,                           //x  4.98387,                       //y  2.92857,                       //z  1.5,                           //{  1.5,                           //|  2.02128,                       //}  1.5,                           //~  1.5f};static INT8 miss_table[256] = {  4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 3, 3, 3, 3, 2,  4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 3, 3, 3, 3, 2,  4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 3, 3, 3, 3, 2,  3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 2, 2, 2, 1,  4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 3, 3, 3, 3, 2,  4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 3, 3, 3, 3, 2,  4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 3, 3, 3, 3, 2,  3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 2, 2, 2, 1,  4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 3, 3, 3, 3, 2,  4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 3, 3, 3, 3, 2,  4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 3, 3, 3, 3, 2,  3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 2, 2, 2, 1,  3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 2, 2, 2, 1,  3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 2, 2, 2, 1,  3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 2, 2, 2, 1,  2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 1, 1, 1, 0};static UINT32 EvidenceTableMask;static UINT32 MultTruncShiftBits;static UINT32 TableTruncShiftBits;UINT32 EvidenceMultMask;static INT16 LocalMatcherMultiplier;make_int_var (ClassPrunerThreshold, 229, MakeClassPrunerThreshold,16, 20, SetClassPrunerThreshold,"Class Pruner Threshold 0-255:        ");make_int_var (ClassPrunerMultiplier, 15, MakeClassPrunerMultiplier,16, 21, SetClassPrunerMultiplier,"Class Pruner Multiplier 0-255:       ");make_int_var (IntegerMatcherMultiplier, 14, MakeIntegerMatcherMultiplier,16, 22, SetIntegerMatcherMultiplier,"Integer Matcher Multiplier  0-255:   ");make_int_var (IntThetaFudge, 128, MakeIntThetaFudge,16, 23, SetIntThetaFudge,"Integer Matcher Theta Fudge 0-255:   ");make_float_var (CPCutoffStrength, 0.15, MakeCPCutoffStrength,16, 24, SetCPCutoffStrength,"Class Pruner CutoffStrength:         ");make_int_var (EvidenceTableBits, 9, MakeEvidenceTableBits,16, 25, SetEvidenceTableBits,"Bits in Similarity to Evidence Lookup  8-9:   ");make_int_var (IntEvidenceTruncBits, 14, MakeIntEvidenceTruncBits,16, 26, SetIntEvidenceTruncBits,"Integer Evidence Truncation Bits (Distance) 8-14:   ");make_float_var (SEExponentialMultiplier, 0, MakeSEExponentialMultiplier,16, 27, SetSEExponentialMultiplier,"Similarity to Evidence Table Exponential Multiplier: ");make_float_var (SimilarityCenter, 0.0075, MakeSimilarityCenter,16, 28, SetSimilarityCenter, "Center of Similarity Curve: ");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -