tesseract  3.03
/usr/local/google/home/jbreiden/tesseract-ocr-read-only/textord/oldbasel.h
Go to the documentation of this file.
00001 /**********************************************************************
00002  * File:        oldbasel.h  (Formerly oldbl.h)
00003  * Description: A re-implementation of the old baseline algorithm.
00004  * Author:              Ray Smith
00005  * Created:             Wed Oct  6 09:41:48 BST 1993
00006  *
00007  * (C) Copyright 1993, Hewlett-Packard Ltd.
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  *
00018  **********************************************************************/
00019 
00020 #ifndef           OLDBASEL_H
00021 #define           OLDBASEL_H
00022 
00023 #include          "params.h"
00024 #include          "blobbox.h"
00025 
00026 extern BOOL_VAR_H (textord_really_old_xheight, FALSE,
00027 "Use original wiseowl xheight");
00028 extern BOOL_VAR_H (textord_oldbl_debug, FALSE,
00029 "Debug old baseline generation");
00030 extern BOOL_VAR_H (textord_debug_baselines, FALSE,
00031 "Debug baseline generation");
00032 extern BOOL_VAR_H (textord_oldbl_paradef, TRUE, "Use para default mechanism");
00033 extern BOOL_VAR_H (textord_oldbl_split_splines, TRUE,
00034 "Split stepped splines");
00035 extern BOOL_VAR_H (textord_oldbl_merge_parts, TRUE,
00036 "Merge suspect partitions");
00037 extern BOOL_VAR_H (oldbl_xhfix, FALSE,
00038 "Fix bug in modes threshold for xheights");
00039 extern INT_VAR_H (oldbl_holed_losscount, 10,
00040 "Max lost before fallback line used");
00041 extern double_VAR_H (oldbl_dot_error_size, 1.26, "Max aspect ratio of a dot");
00042 extern double_VAR_H (textord_oldbl_jumplimit, 0.15,
00043 "X fraction for new partition");
00044 int get_blob_coords(                    //get boxes
00045                     TO_ROW *row,        //row to use
00046                     inT32 lineheight,   //block level
00047                     TBOX *blobcoords,    //ouput boxes
00048                     BOOL8 &holed_line,  //lost a lot of blobs
00049                     int &outcount       //no of real blobs
00050                    );
00051 void make_first_baseline (       //initial approximation
00052 TBOX blobcoords[],                /*blob bounding boxes */
00053 int blobcount,                   /*no of blobcoords */
00054 int xcoords[],                   /*coords for spline */
00055 int ycoords[],                   /*approximator */
00056 QSPLINE * spline,                /*initial spline */
00057 QSPLINE * baseline,              /*output spline */
00058 float jumplimit                  /*guess half descenders */
00059 );
00060 void make_holed_baseline (       //initial approximation
00061 TBOX blobcoords[],                /*blob bounding boxes */
00062 int blobcount,                   /*no of blobcoords */
00063 QSPLINE * spline,                /*initial spline */
00064 QSPLINE * baseline,              /*output spline */
00065 float gradient                   //of line
00066 );
00067 int partition_line (             //partition blobs
00068 TBOX blobcoords[],                //bounding boxes
00069 int blobcount,                   /*no of blobs on row */
00070 int *numparts,                   /*number of partitions */
00071 char partids[],                  /*partition no of each blob */
00072 int partsizes[],                 /*no in each partition */
00073 QSPLINE * spline,                /*curve to fit to */
00074 float jumplimit,                 /*allowed delta change */
00075 float ydiffs[]                   /*diff from spline */
00076 );
00077 void merge_oldbl_parts (         //partition blobs
00078 TBOX blobcoords[],                //bounding boxes
00079 int blobcount,                   /*no of blobs on row */
00080 char partids[],                  /*partition no of each blob */
00081 int partsizes[],                 /*no in each partition */
00082 int biggestpart,                 //major partition
00083 float jumplimit                  /*allowed delta change */
00084 );
00085 int get_ydiffs (                 //evaluate differences
00086 TBOX blobcoords[],                //bounding boxes
00087 int blobcount,                   /*no of blobs */
00088 QSPLINE * spline,                /*approximating spline */
00089 float ydiffs[]                   /*output */
00090 );
00091 int choose_partition (           //select partition
00092 register float diff,             /*diff from spline */
00093 float partdiffs[],               /*diff on all parts */
00094 int lastpart,                    /*last assigned partition */
00095 float jumplimit,                 /*new part threshold */
00096 float* drift,
00097 float* last_delta,
00098 int *partcount                   /*no of partitions */
00099 );
00100 int partition_coords (           //find relevant coords
00101 TBOX blobcoords[],                //bounding boxes
00102 int blobcount,                   /*no of blobs in row */
00103 char partids[],                  /*partition no of each blob */
00104 int bestpart,                    /*best new partition */
00105 int xcoords[],                   /*points to work on */
00106 int ycoords[]                    /*points to work on */
00107 );
00108 int segment_spline (             //make xstarts
00109 TBOX blobcoords[],                //boundign boxes
00110 int blobcount,                   /*no of blobs in row */
00111 int xcoords[],                   /*points to work on */
00112 int ycoords[],                   /*points to work on */
00113 int degree, int pointcount,      /*no of points */
00114 int xstarts[]                    //result
00115 );
00116 BOOL8 split_stepped_spline (     //make xstarts
00117 QSPLINE * baseline,              //current shot
00118 float jumplimit,                 //max step fuction
00119 int xcoords[],                   /*points to work on */
00120 int xstarts[],                   //result
00121 int &segments                    //no of segments
00122 );
00123 void insert_spline_point (       //get descenders
00124 int xstarts[],                   //starts to shuffle
00125 int segment,                     //insertion pt
00126 int coord1,                      //coords to add
00127 int coord2, int &segments        //total segments
00128 );
00129 void find_lesser_parts (         //get descenders
00130 TO_ROW * row,                    //row to process
00131 TBOX blobcoords[],                //bounding boxes
00132 int blobcount,                   /*no of blobs */
00133 char partids[],                  /*partition of each blob */
00134 int partsizes[],                 /*size of each part */
00135 int partcount,                   /*no of partitions */
00136 int bestpart                     /*biggest partition */
00137 );
00138 
00139 void old_first_xheight (         //the wiseowl way
00140 TO_ROW * row,                    /*current row */
00141 TBOX blobcoords[],                /*blob bounding boxes */
00142 int initialheight,               //initial guess
00143 int blobcount,                   /*blobs in blobcoords */
00144 QSPLINE * baseline,              /*established */
00145 float jumplimit                  /*min ascender height */
00146 );
00147 
00148 void make_first_xheight (        //find xheight
00149 TO_ROW * row,                    /*current row */
00150 TBOX blobcoords[],                /*blob bounding boxes */
00151 int lineheight,                  //initial guess
00152 int init_lineheight,             //block level guess
00153 int blobcount,                   /*blobs in blobcoords */
00154 QSPLINE * baseline,              /*established */
00155 float jumplimit                  /*min ascender height */
00156 );
00157 
00158 int *make_height_array (         //get array of heights
00159 TBOX blobcoords[],                /*blob bounding boxes */
00160 int blobcount,                   /*blobs in blobcoords */
00161 QSPLINE * baseline               /*established */
00162 );
00163 
00164 void find_top_modes (            //get modes
00165 STATS * stats,                   //stats to hack
00166 int statnum,                     //no of piles
00167 int modelist[], int modenum      //no of modes to get
00168 );
00169 
00170 void pick_x_height(TO_ROW * row,                    //row to do
00171 int modelist[],
00172 int lefts[], int rights[],
00173 STATS * heightstat,
00174 int mode_threshold);
00175 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines