Tesseract  3.02
tesseract-ocr/training/mergenf.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 **      Filename:    MergeNF.c
00003 **      Purpose:     Program for merging similar nano-feature protos
00004 **      Author:      Dan Johnson
00005 **      History:     Wed Nov 21 09:55:23 1990, DSJ, Created.
00006 **
00007  **     (c) Copyright Hewlett-Packard Company, 1988.
00008  ** Licensed under the Apache License, Version 2.0 (the "License");
00009  ** you may not use this file except in compliance with the License.
00010  ** You may obtain a copy of the License at
00011  ** http://www.apache.org/licenses/LICENSE-2.0
00012  ** Unless required by applicable law or agreed to in writing, software
00013  ** distributed under the License is distributed on an "AS IS" BASIS,
00014  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  ** See the License for the specific language governing permissions and
00016  ** limitations under the License.
00017 ******************************************************************************/
00021 #include "protos.h"
00022 #include "cluster.h"
00023 #include "ocrfeatures.h"
00024 #include "callcpp.h"
00025 #include "picofeat.h"
00026 
00027 
00028 #define WORST_MATCH_ALLOWED     (0.9)
00029 #define WORST_EVIDENCE (1.0)
00030 #define MAX_LENGTH_MISMATCH     (2.0 * GetPicoFeatureLength ())
00031 
00032 
00033 #define PROTO_SUFFIX            ".mf.p"
00034 #define CONFIG_SUFFIX           ".cl"
00035 #define NO_PROTO        (-1)
00036 #define XPOSITION                       0
00037 #define YPOSITION                       1
00038 #define MFLENGTH                        2
00039 #define ORIENTATION                     3
00040 
00041 typedef struct
00042 {
00043   FLOAT32       MinX, MaxX, MinY, MaxY;
00044 } FRECT;
00045 
00049 #define CenterX(M)              ( (M)[XPOSITION] )
00050 #define CenterY(M)              ( (M)[YPOSITION] )
00051 #define LengthOf(M)             ( (M)[MFLENGTH] )
00052 #define OrientationOf(M)        ( (M)[ORIENTATION] )
00053 
00057 FLOAT32 CompareProtos (
00058      PROTO      p1,
00059          PROTO  p2);
00060 
00061 void ComputeMergedProto (
00062      PROTO      p1,
00063          PROTO  p2,
00064      FLOAT32    w1,
00065          FLOAT32        w2,
00066      PROTO      MergedProto);
00067 
00068 int FindClosestExistingProto (
00069      CLASS_TYPE Class,
00070      int        NumMerged[],
00071      PROTOTYPE  *Prototype);
00072 
00073 void MakeNewFromOld (
00074      PROTO      New,
00075      PROTOTYPE  *Old);
00076 
00077 FLOAT32 SubfeatureEvidence (
00078    FEATURE     Feature,
00079    PROTO       Proto);
00080 
00081 double EvidenceOf (
00082   register double   Similarity);
00083 
00084 BOOL8 DummyFastMatch (
00085      FEATURE    Feature,
00086      PROTO      Proto);
00087 
00088 void ComputePaddedBoundingBox (
00089      PROTO      Proto,
00090      FLOAT32    TangentPad,
00091          FLOAT32        OrthogonalPad,
00092      FRECT      *BoundingBox);
00093 
00094 BOOL8 PointInside (
00095      FRECT      *Rectangle,
00096      FLOAT32    X,
00097          FLOAT32        Y);