Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
topitch.h
Go to the documentation of this file.
1 /**********************************************************************
2  * File: topitch.h (Formerly to_pitch.h)
3  * Description: Code to determine fixed pitchness and the pitch if fixed.
4  * Author: Ray Smith
5  * Created: Tue Aug 24 16:57:29 BST 1993
6  *
7  * (C) Copyright 1993, Hewlett-Packard Ltd.
8  ** Licensed under the Apache License, Version 2.0 (the "License");
9  ** you may not use this file except in compliance with the License.
10  ** You may obtain a copy of the License at
11  ** http://www.apache.org/licenses/LICENSE-2.0
12  ** Unless required by applicable law or agreed to in writing, software
13  ** distributed under the License is distributed on an "AS IS" BASIS,
14  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  ** See the License for the specific language governing permissions and
16  ** limitations under the License.
17  *
18  **********************************************************************/
19 
20 #ifndef TOPITCH_H
21 #define TOPITCH_H
22 
23 #include "blobbox.h"
24 #include "notdll.h"
25 
26 namespace tesseract {
27 class Tesseract;
28 }
30 "Debug on fixed pitch test");
32 "Write full metric stuff");
33 extern BOOL_VAR_H (textord_show_row_cuts, FALSE, "Draw row-level cuts");
34 extern BOOL_VAR_H (textord_show_page_cuts, FALSE, "Draw page-level cuts");
36 "Use correct answer for fixed/prop");
38 "Attempt whole doc/block fixed pitch");
40 "Do even faster pitch algorithm");
42 "Ding rate for mid-cuts");
44 "Ding rate for unbalanced char cells");
45 
46 void compute_fixed_pitch(ICOORD page_tr, // top right
47  TO_BLOCK_LIST *port_blocks, // input list
48  float gradient, // page skew
49  FCOORD rotation, // for drawing
50  BOOL8 testing_on); // correct orientation
51 void fix_row_pitch( //get some value
52  TO_ROW *bad_row, //row to fix
53  TO_BLOCK *bad_block, //block of bad_row
54  TO_BLOCK_LIST *blocks, //blocks to scan
55  inT32 row_target, //number of row
56  inT32 block_target //number of block
57  );
58 void compute_block_pitch( TO_BLOCK *block, // input list
59  FCOORD rotation, // for drawing
60  inT32 block_index, // block number
61  BOOL8 testing_on); // correct orientation
62 BOOL8 compute_rows_pitch( //find line stats
63  TO_BLOCK *block, //block to do
64  inT32 block_index, //block number
65  BOOL8 testing_on //correct orientation
66  );
67 BOOL8 try_doc_fixed( //determine pitch
68  ICOORD page_tr, //top right
69  TO_BLOCK_LIST *port_blocks, //input list
70  float gradient //page skew
71  );
72 BOOL8 try_block_fixed( //find line stats
73  TO_BLOCK *block, //block to do
74  inT32 block_index //block number
75  );
76 BOOL8 try_rows_fixed( //find line stats
77  TO_BLOCK *block, //block to do
78  inT32 block_index, //block number
79  BOOL8 testing_on //correct orientation
80  );
81 void print_block_counts( //find line stats
82  TO_BLOCK *block, //block to do
83  inT32 block_index //block number
84  );
85 void count_block_votes( //find line stats
86  TO_BLOCK *block, //block to do
87  inT32 &def_fixed, //add to counts
88  inT32 &def_prop,
89  inT32 &maybe_fixed,
90  inT32 &maybe_prop,
91  inT32 &corr_fixed,
92  inT32 &corr_prop,
93  inT32 &dunno);
94 BOOL8 row_pitch_stats( //find line stats
95  TO_ROW *row, //current row
96  inT32 maxwidth, //of spaces
97  BOOL8 testing_on //correct orientation
98  );
99 BOOL8 find_row_pitch( //find lines
100  TO_ROW *row, //row to do
101  inT32 maxwidth, //max permitted space
102  inT32 dm_gap, //ignorable gaps
103  TO_BLOCK *block, //block of row
104  inT32 block_index, //block_number
105  inT32 row_index, //number of row
106  BOOL8 testing_on //correct orientation
107  );
108 BOOL8 fixed_pitch_row( //find lines
109  TO_ROW *row, //row to do
110  BLOCK* block,
111  inT32 block_index //block_number
112  );
113 BOOL8 count_pitch_stats( //find lines
114  TO_ROW *row, //row to do
115  STATS *gap_stats, //blob gaps
116  STATS *pitch_stats, //centre-centre stats
117  float initial_pitch, //guess at pitch
118  float min_space, //estimate space size
119  BOOL8 ignore_outsize, //discard big objects
120  BOOL8 split_outsize, //split big objects
121  inT32 dm_gap //ignorable gaps
122  );
123 float tune_row_pitch( //find fp cells
124  TO_ROW *row, //row to do
125  STATS *projection, //vertical projection
126  inT16 projection_left, //edge of projection
127  inT16 projection_right, //edge of projection
128  float space_size, //size of blank
129  float &initial_pitch, //guess at pitch
130  float &best_sp_sd, //space sd
131  inT16 &best_mid_cuts, //no of cheap cuts
132  ICOORDELT_LIST *best_cells, //row cells
133  BOOL8 testing_on //inidividual words
134  );
135 float tune_row_pitch2( //find fp cells
136  TO_ROW *row, //row to do
137  STATS *projection, //vertical projection
138  inT16 projection_left, //edge of projection
139  inT16 projection_right, //edge of projection
140  float space_size, //size of blank
141  float &initial_pitch, //guess at pitch
142  float &best_sp_sd, //space sd
143  inT16 &best_mid_cuts, //no of cheap cuts
144  ICOORDELT_LIST *best_cells, //row cells
145  BOOL8 testing_on //inidividual words
146  );
147 float compute_pitch_sd ( //find fp cells
148 TO_ROW * row, //row to do
149 STATS * projection, //vertical projection
150 inT16 projection_left, //edge
151 inT16 projection_right, //edge
152 float space_size, //size of blank
153 float initial_pitch, //guess at pitch
154 float &sp_sd, //space sd
155 inT16 & mid_cuts, //no of free cuts
156 ICOORDELT_LIST * row_cells, //list of chop pts
157 BOOL8 testing_on, //inidividual words
158 inT16 start = 0, //start of good range
159 inT16 end = 0 //end of good range
160 );
161 float compute_pitch_sd2 ( //find fp cells
162 TO_ROW * row, //row to do
163 STATS * projection, //vertical projection
164 inT16 projection_left, //edge
165 inT16 projection_right, //edge
166 float initial_pitch, //guess at pitch
167 inT16 & occupation, //no of occupied cells
168 inT16 & mid_cuts, //no of free cuts
169 ICOORDELT_LIST * row_cells, //list of chop pts
170 BOOL8 testing_on, //inidividual words
171 inT16 start = 0, //start of good range
172 inT16 end = 0 //end of good range
173 );
174 void print_pitch_sd( //find fp cells
175  TO_ROW *row, //row to do
176  STATS *projection, //vertical projection
177  inT16 projection_left, //edges //size of blank
178  inT16 projection_right,
179  float space_size,
180  float initial_pitch //guess at pitch
181  );
182 void find_repeated_chars(TO_BLOCK *block, // Block to search.
183  BOOL8 testing_on); // Debug mode.
184 void plot_fp_word( //draw block of words
185  TO_BLOCK *block, //block to draw
186  float pitch, //pitch to draw with
187  float nonspace //for space threshold
188  );
189 #endif