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
void print_pitch_sd(TO_ROW *row, STATS *projection, inT16 projection_left, inT16 projection_right, float space_size, float initial_pitch)
Definition: topitch.cpp:1634
bool textord_show_row_cuts
Definition: topitch.cpp:53
BOOL8 row_pitch_stats(TO_ROW *row, inT32 maxwidth, BOOL8 testing_on)
Definition: topitch.cpp:706
float tune_row_pitch(TO_ROW *row, STATS *projection, inT16 projection_left, inT16 projection_right, float space_size, float &initial_pitch, float &best_sp_sd, inT16 &best_mid_cuts, ICOORDELT_LIST *best_cells, BOOL8 testing_on)
Definition: topitch.cpp:1150
bool textord_debug_pitch_test
Definition: topitch.cpp:46
void compute_block_pitch(TO_BLOCK *block, FCOORD rotation, inT32 block_index, BOOL8 testing_on)
Definition: topitch.cpp:311
#define BOOL_VAR_H(name, val, comment)
Definition: params.h:239
void compute_fixed_pitch(ICOORD page_tr, TO_BLOCK_LIST *port_blocks, float gradient, FCOORD rotation, BOOL8 testing_on)
Definition: topitch.cpp:75
void find_repeated_chars(TO_BLOCK *block, BOOL8 testing_on)
Definition: topitch.cpp:1762
BOOL8 count_pitch_stats(TO_ROW *row, STATS *gap_stats, STATS *pitch_stats, float initial_pitch, float min_space, BOOL8 ignore_outsize, BOOL8 split_outsize, inT32 dm_gap)
Definition: topitch.cpp:1062
float compute_pitch_sd(TO_ROW *row, STATS *projection, inT16 projection_left, inT16 projection_right, float space_size, float initial_pitch, float &sp_sd, inT16 &mid_cuts, ICOORDELT_LIST *row_cells, BOOL8 testing_on, inT16 start=0, inT16 end=0)
Definition: topitch.cpp:1379
bool textord_show_page_cuts
Definition: topitch.cpp:54
unsigned char BOOL8
Definition: host.h:113
BOOL8 try_rows_fixed(TO_BLOCK *block, inT32 block_index, BOOL8 testing_on)
Definition: topitch.cpp:552
void plot_fp_word(TO_BLOCK *block, float pitch, float nonspace)
Definition: topitch.cpp:1828
double textord_balance_factor
Definition: topitch.cpp:61
int inT32
Definition: host.h:102
BOOL8 find_row_pitch(TO_ROW *row, inT32 maxwidth, inT32 dm_gap, TO_BLOCK *block, inT32 block_index, inT32 row_index, BOOL8 testing_on)
Definition: topitch.cpp:839
#define FALSE
Definition: capi.h:28
void fix_row_pitch(TO_ROW *bad_row, TO_BLOCK *bad_block, TO_BLOCK_LIST *blocks, inT32 row_target, inT32 block_target)
Definition: topitch.cpp:144
BOOL8 try_doc_fixed(ICOORD page_tr, TO_BLOCK_LIST *port_blocks, float gradient)
Definition: topitch.cpp:398
#define double_VAR_H(name, val, comment)
Definition: params.h:245
bool textord_blockndoc_fixed
Definition: topitch.cpp:58
void count_block_votes(TO_BLOCK *block, inT32 &def_fixed, inT32 &def_prop, inT32 &maybe_fixed, inT32 &maybe_prop, inT32 &corr_fixed, inT32 &corr_prop, inT32 &dunno)
Definition: topitch.cpp:659
bool textord_pitch_cheat
Definition: topitch.cpp:56
Definition: ocrblock.h:31
bool textord_fast_pitch_test
Definition: topitch.cpp:50
bool textord_debug_pitch_metric
Definition: topitch.cpp:52
Definition: points.h:189
short inT16
Definition: host.h:100
Definition: statistc.h:29
integer coordinate
Definition: points.h:30
BOOL8 fixed_pitch_row(TO_ROW *row, BLOCK *block, inT32 block_index)
Definition: topitch.cpp:979
void print_block_counts(TO_BLOCK *block, inT32 block_index)
Definition: topitch.cpp:622
float tune_row_pitch2(TO_ROW *row, STATS *projection, inT16 projection_left, inT16 projection_right, float space_size, float &initial_pitch, float &best_sp_sd, inT16 &best_mid_cuts, ICOORDELT_LIST *best_cells, BOOL8 testing_on)
Definition: topitch.cpp:1262
BOOL8 try_block_fixed(TO_BLOCK *block, inT32 block_index)
Definition: topitch.cpp:538
double textord_projection_scale
Definition: topitch.cpp:59
float compute_pitch_sd2(TO_ROW *row, STATS *projection, inT16 projection_left, inT16 projection_right, float initial_pitch, inT16 &occupation, inT16 &mid_cuts, ICOORDELT_LIST *row_cells, BOOL8 testing_on, inT16 start=0, inT16 end=0)
Definition: topitch.cpp:1542
#define TRUE
Definition: capi.h:27
BOOL8 compute_rows_pitch(TO_BLOCK *block, inT32 block_index, BOOL8 testing_on)
Definition: topitch.cpp:354