tesseract  3.03
/usr/local/google/home/jbreiden/tesseract-ocr-read-only/textord/topitch.h
Go to the documentation of this file.
00001 /**********************************************************************
00002  * File:        topitch.h  (Formerly to_pitch.h)
00003  * Description: Code to determine fixed pitchness and the pitch if fixed.
00004  * Author:              Ray Smith
00005  * Created:             Tue Aug 24 16:57:29 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           TOPITCH_H
00021 #define           TOPITCH_H
00022 
00023 #include          "blobbox.h"
00024 
00025 namespace tesseract {
00026 class Tesseract;
00027 }
00028 extern BOOL_VAR_H (textord_debug_pitch_test, FALSE,
00029 "Debug on fixed pitch test");
00030 extern BOOL_VAR_H (textord_debug_pitch_metric, FALSE,
00031 "Write full metric stuff");
00032 extern BOOL_VAR_H (textord_show_row_cuts, FALSE, "Draw row-level cuts");
00033 extern BOOL_VAR_H (textord_show_page_cuts, FALSE, "Draw page-level cuts");
00034 extern BOOL_VAR_H (textord_pitch_cheat, FALSE,
00035 "Use correct answer for fixed/prop");
00036 extern BOOL_VAR_H (textord_blockndoc_fixed, TRUE,
00037 "Attempt whole doc/block fixed pitch");
00038 extern BOOL_VAR_H (textord_fast_pitch_test, FALSE,
00039 "Do even faster pitch algorithm");
00040 extern double_VAR_H (textord_projection_scale, 0.125,
00041 "Ding rate for mid-cuts");
00042 extern double_VAR_H (textord_balance_factor, 2.0,
00043 "Ding rate for unbalanced char cells");
00044 
00045 void compute_fixed_pitch(ICOORD page_tr,              // top right
00046                          TO_BLOCK_LIST *port_blocks,  // input list
00047                          float gradient,              // page skew
00048                          FCOORD rotation,             // for drawing
00049                          BOOL8 testing_on);           // correct orientation
00050 void fix_row_pitch(                        //get some value
00051                    TO_ROW *bad_row,        //row to fix
00052                    TO_BLOCK *bad_block,    //block of bad_row
00053                    TO_BLOCK_LIST *blocks,  //blocks to scan
00054                    inT32 row_target,       //number of row
00055                    inT32 block_target      //number of block
00056                   );
00057 void compute_block_pitch( TO_BLOCK *block,     // input list
00058                          FCOORD rotation,      // for drawing
00059                          inT32 block_index,    // block number
00060                          BOOL8 testing_on);    // correct orientation
00061 BOOL8 compute_rows_pitch(                    //find line stats
00062                          TO_BLOCK *block,    //block to do
00063                          inT32 block_index,  //block number
00064                          BOOL8 testing_on    //correct orientation
00065                         );
00066 BOOL8 try_doc_fixed(                             //determine pitch
00067                     ICOORD page_tr,              //top right
00068                     TO_BLOCK_LIST *port_blocks,  //input list
00069                     float gradient               //page skew
00070                    );
00071 BOOL8 try_block_fixed(                   //find line stats
00072                       TO_BLOCK *block,   //block to do
00073                       inT32 block_index  //block number
00074                      );
00075 BOOL8 try_rows_fixed(                    //find line stats
00076                      TO_BLOCK *block,    //block to do
00077                      inT32 block_index,  //block number
00078                      BOOL8 testing_on    //correct orientation
00079                     );
00080 void print_block_counts(                   //find line stats
00081                         TO_BLOCK *block,   //block to do
00082                         inT32 block_index  //block number
00083                        );
00084 void count_block_votes(                   //find line stats
00085                        TO_BLOCK *block,   //block to do
00086                        inT32 &def_fixed,  //add to counts
00087                        inT32 &def_prop,
00088                        inT32 &maybe_fixed,
00089                        inT32 &maybe_prop,
00090                        inT32 &corr_fixed,
00091                        inT32 &corr_prop,
00092                        inT32 &dunno);
00093 BOOL8 row_pitch_stats(                  //find line stats
00094                       TO_ROW *row,      //current row
00095                       inT32 maxwidth,   //of spaces
00096                       BOOL8 testing_on  //correct orientation
00097                      );
00098 BOOL8 find_row_pitch(                    //find lines
00099                      TO_ROW *row,        //row to do
00100                      inT32 maxwidth,     //max permitted space
00101                      inT32 dm_gap,       //ignorable gaps
00102                      TO_BLOCK *block,    //block of row
00103                      inT32 block_index,  //block_number
00104                      inT32 row_index,    //number of row
00105                      BOOL8 testing_on    //correct orientation
00106                     );
00107 BOOL8 fixed_pitch_row(                   //find lines
00108                       TO_ROW *row,       //row to do
00109                       BLOCK* block,
00110                       inT32 block_index  //block_number
00111                      );
00112 BOOL8 count_pitch_stats(                       //find lines
00113                         TO_ROW *row,           //row to do
00114                         STATS *gap_stats,      //blob gaps
00115                         STATS *pitch_stats,    //centre-centre stats
00116                         float initial_pitch,   //guess at pitch
00117                         float min_space,       //estimate space size
00118                         BOOL8 ignore_outsize,  //discard big objects
00119                         BOOL8 split_outsize,   //split big objects
00120                         inT32 dm_gap           //ignorable gaps
00121                        );
00122 float tune_row_pitch(                             //find fp cells
00123                      TO_ROW *row,                 //row to do
00124                      STATS *projection,           //vertical projection
00125                      inT16 projection_left,       //edge of projection
00126                      inT16 projection_right,      //edge of projection
00127                      float space_size,            //size of blank
00128                      float &initial_pitch,        //guess at pitch
00129                      float &best_sp_sd,           //space sd
00130                      inT16 &best_mid_cuts,        //no of cheap cuts
00131                      ICOORDELT_LIST *best_cells,  //row cells
00132                      BOOL8 testing_on             //inidividual words
00133                     );
00134 float tune_row_pitch2(                             //find fp cells
00135                       TO_ROW *row,                 //row to do
00136                       STATS *projection,           //vertical projection
00137                       inT16 projection_left,       //edge of projection
00138                       inT16 projection_right,      //edge of projection
00139                       float space_size,            //size of blank
00140                       float &initial_pitch,        //guess at pitch
00141                       float &best_sp_sd,           //space sd
00142                       inT16 &best_mid_cuts,        //no of cheap cuts
00143                       ICOORDELT_LIST *best_cells,  //row cells
00144                       BOOL8 testing_on             //inidividual words
00145                      );
00146 float compute_pitch_sd (         //find fp cells
00147 TO_ROW * row,                    //row to do
00148 STATS * projection,              //vertical projection
00149 inT16 projection_left,           //edge
00150 inT16 projection_right,          //edge
00151 float space_size,                //size of blank
00152 float initial_pitch,             //guess at pitch
00153 float &sp_sd,                    //space sd
00154 inT16 & mid_cuts,                //no of free cuts
00155 ICOORDELT_LIST * row_cells,      //list of chop pts
00156 BOOL8 testing_on,                //inidividual words
00157 inT16 start = 0,                 //start of good range
00158 inT16 end = 0                    //end of good range
00159 );
00160 float compute_pitch_sd2 (        //find fp cells
00161 TO_ROW * row,                    //row to do
00162 STATS * projection,              //vertical projection
00163 inT16 projection_left,           //edge
00164 inT16 projection_right,          //edge
00165 float initial_pitch,             //guess at pitch
00166 inT16 & occupation,              //no of occupied cells
00167 inT16 & mid_cuts,                //no of free cuts
00168 ICOORDELT_LIST * row_cells,      //list of chop pts
00169 BOOL8 testing_on,                //inidividual words
00170 inT16 start = 0,                 //start of good range
00171 inT16 end = 0                    //end of good range
00172 );
00173 void print_pitch_sd(                        //find fp cells
00174                     TO_ROW *row,            //row to do
00175                     STATS *projection,      //vertical projection
00176                     inT16 projection_left,  //edges //size of blank
00177                     inT16 projection_right,
00178                     float space_size,
00179                     float initial_pitch     //guess at pitch
00180                    );
00181 void find_repeated_chars(TO_BLOCK *block,    // Block to search.
00182                          BOOL8 testing_on);  // Debug mode.
00183 void plot_fp_word(                  //draw block of words
00184                   TO_BLOCK *block,  //block to draw
00185                   float pitch,      //pitch to draw with
00186                   float nonspace    //for space threshold
00187                  );
00188 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines