All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  **
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  **********************************************************************/
20 #ifndef TOPITCH_H
21 #define TOPITCH_H
23 #include "blobbox.h"
25 namespace tesseract {
26 class Tesseract;
27 }
29 "Debug on fixed pitch test");
31 "Write full metric stuff");
32 extern BOOL_VAR_H (textord_show_row_cuts, FALSE, "Draw row-level cuts");
33 extern BOOL_VAR_H (textord_show_page_cuts, FALSE, "Draw page-level cuts");
35 "Use correct answer for fixed/prop");
37 "Attempt whole doc/block fixed pitch");
39 "Do even faster pitch algorithm");
41 "Ding rate for mid-cuts");
43 "Ding rate for unbalanced char cells");
45 void compute_fixed_pitch(ICOORD page_tr, // top right
46  TO_BLOCK_LIST *port_blocks, // input list
47  float gradient, // page skew
48  FCOORD rotation, // for drawing
49  BOOL8 testing_on); // correct orientation
50 void fix_row_pitch( //get some value
51  TO_ROW *bad_row, //row to fix
52  TO_BLOCK *bad_block, //block of bad_row
53  TO_BLOCK_LIST *blocks, //blocks to scan
54  inT32 row_target, //number of row
55  inT32 block_target //number of block
56  );
57 void compute_block_pitch( TO_BLOCK *block, // input list
58  FCOORD rotation, // for drawing
59  inT32 block_index, // block number
60  BOOL8 testing_on); // correct orientation
61 BOOL8 compute_rows_pitch( //find line stats
62  TO_BLOCK *block, //block to do
63  inT32 block_index, //block number
64  BOOL8 testing_on //correct orientation
65  );
66 BOOL8 try_doc_fixed( //determine pitch
67  ICOORD page_tr, //top right
68  TO_BLOCK_LIST *port_blocks, //input list
69  float gradient //page skew
70  );
71 BOOL8 try_block_fixed( //find line stats
72  TO_BLOCK *block, //block to do
73  inT32 block_index //block number
74  );
75 BOOL8 try_rows_fixed( //find line stats
76  TO_BLOCK *block, //block to do
77  inT32 block_index, //block number
78  BOOL8 testing_on //correct orientation
79  );
80 void print_block_counts( //find line stats
81  TO_BLOCK *block, //block to do
82  inT32 block_index //block number
83  );
84 void count_block_votes( //find line stats
85  TO_BLOCK *block, //block to do
86  inT32 &def_fixed, //add to counts
87  inT32 &def_prop,
88  inT32 &maybe_fixed,
89  inT32 &maybe_prop,
90  inT32 &corr_fixed,
91  inT32 &corr_prop,
92  inT32 &dunno);
93 BOOL8 row_pitch_stats( //find line stats
94  TO_ROW *row, //current row
95  inT32 maxwidth, //of spaces
96  BOOL8 testing_on //correct orientation
97  );
98 BOOL8 find_row_pitch( //find lines
99  TO_ROW *row, //row to do
100  inT32 maxwidth, //max permitted space
101  inT32 dm_gap, //ignorable gaps
102  TO_BLOCK *block, //block of row
103  inT32 block_index, //block_number
104  inT32 row_index, //number of row
105  BOOL8 testing_on //correct orientation
106  );
107 BOOL8 fixed_pitch_row( //find lines
108  TO_ROW *row, //row to do
109  BLOCK* block,
110  inT32 block_index //block_number
111  );
112 BOOL8 count_pitch_stats( //find lines
113  TO_ROW *row, //row to do
114  STATS *gap_stats, //blob gaps
115  STATS *pitch_stats, //centre-centre stats
116  float initial_pitch, //guess at pitch
117  float min_space, //estimate space size
118  BOOL8 ignore_outsize, //discard big objects
119  BOOL8 split_outsize, //split big objects
120  inT32 dm_gap //ignorable gaps
121  );
122 float tune_row_pitch( //find fp cells
123  TO_ROW *row, //row to do
124  STATS *projection, //vertical projection
125  inT16 projection_left, //edge of projection
126  inT16 projection_right, //edge of projection
127  float space_size, //size of blank
128  float &initial_pitch, //guess at pitch
129  float &best_sp_sd, //space sd
130  inT16 &best_mid_cuts, //no of cheap cuts
131  ICOORDELT_LIST *best_cells, //row cells
132  BOOL8 testing_on //inidividual words
133  );
134 float tune_row_pitch2( //find fp cells
135  TO_ROW *row, //row to do
136  STATS *projection, //vertical projection
137  inT16 projection_left, //edge of projection
138  inT16 projection_right, //edge of projection
139  float space_size, //size of blank
140  float &initial_pitch, //guess at pitch
141  float &best_sp_sd, //space sd
142  inT16 &best_mid_cuts, //no of cheap cuts
143  ICOORDELT_LIST *best_cells, //row cells
144  BOOL8 testing_on //inidividual words
145  );
146 float compute_pitch_sd ( //find fp cells
147 TO_ROW * row, //row to do
148 STATS * projection, //vertical projection
149 inT16 projection_left, //edge
150 inT16 projection_right, //edge
151 float space_size, //size of blank
152 float initial_pitch, //guess at pitch
153 float &sp_sd, //space sd
154 inT16 & mid_cuts, //no of free cuts
155 ICOORDELT_LIST * row_cells, //list of chop pts
156 BOOL8 testing_on, //inidividual words
157 inT16 start = 0, //start of good range
158 inT16 end = 0 //end of good range
159 );
160 float compute_pitch_sd2 ( //find fp cells
161 TO_ROW * row, //row to do
162 STATS * projection, //vertical projection
163 inT16 projection_left, //edge
164 inT16 projection_right, //edge
165 float initial_pitch, //guess at pitch
166 inT16 & occupation, //no of occupied cells
167 inT16 & mid_cuts, //no of free cuts
168 ICOORDELT_LIST * row_cells, //list of chop pts
169 BOOL8 testing_on, //inidividual words
170 inT16 start = 0, //start of good range
171 inT16 end = 0 //end of good range
172 );
173 void print_pitch_sd( //find fp cells
174  TO_ROW *row, //row to do
175  STATS *projection, //vertical projection
176  inT16 projection_left, //edges //size of blank
177  inT16 projection_right,
178  float space_size,
179  float initial_pitch //guess at pitch
180  );
181 void find_repeated_chars(TO_BLOCK *block, // Block to search.
182  BOOL8 testing_on); // Debug mode.
183 void plot_fp_word( //draw block of words
184  TO_BLOCK *block, //block to draw
185  float pitch, //pitch to draw with
186  float nonspace //for space threshold
187  );
188 #endif
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:1258
void print_block_counts(TO_BLOCK *block, inT32 block_index)
Definition: topitch.cpp:617
BOOL8 compute_rows_pitch(TO_BLOCK *block, inT32 block_index, BOOL8 testing_on)
Definition: topitch.cpp:351
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:1538
Definition: statistc.h:33
void plot_fp_word(TO_BLOCK *block, float pitch, float nonspace)
Definition: topitch.cpp:1824
unsigned char BOOL8
Definition: host.h:113
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:1058
void print_pitch_sd(TO_ROW *row, STATS *projection, inT16 projection_left, inT16 projection_right, float space_size, float initial_pitch)
Definition: topitch.cpp:1630
bool textord_debug_pitch_metric
Definition: topitch.cpp:50
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:834
bool textord_fast_pitch_test
Definition: topitch.cpp:48
bool textord_show_page_cuts
Definition: topitch.cpp:52
void compute_block_pitch(TO_BLOCK *block, FCOORD rotation, inT32 block_index, BOOL8 testing_on)
Definition: topitch.cpp:308
double textord_balance_factor
Definition: topitch.cpp:59
double textord_projection_scale
Definition: topitch.cpp:57
BOOL8 try_block_fixed(TO_BLOCK *block, inT32 block_index)
Definition: topitch.cpp:535
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:1146
void find_repeated_chars(TO_BLOCK *block, BOOL8 testing_on)
Definition: topitch.cpp:1758
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:142
Definition: ocrblock.h:30
bool textord_debug_pitch_test
Definition: topitch.cpp:44
BOOL8 fixed_pitch_row(TO_ROW *row, BLOCK *block, inT32 block_index)
Definition: topitch.cpp:974
#define double_VAR_H(name, val, comment)
Definition: params.h:274
BOOL8 row_pitch_stats(TO_ROW *row, inT32 maxwidth, BOOL8 testing_on)
Definition: topitch.cpp:701
integer coordinate
Definition: points.h:30
BOOL8 try_doc_fixed(ICOORD page_tr, TO_BLOCK_LIST *port_blocks, float gradient)
Definition: topitch.cpp:395
#define FALSE
Definition: capi.h:29
bool textord_show_row_cuts
Definition: topitch.cpp:51
bool textord_pitch_cheat
Definition: topitch.cpp:54
#define TRUE
Definition: capi.h:28
BOOL8 try_rows_fixed(TO_BLOCK *block, inT32 block_index, BOOL8 testing_on)
Definition: topitch.cpp:549
bool textord_blockndoc_fixed
Definition: topitch.cpp:56
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:654
#define BOOL_VAR_H(name, val, comment)
Definition: params.h:268
Definition: points.h:189
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:1375
void compute_fixed_pitch(ICOORD page_tr, TO_BLOCK_LIST *port_blocks, float gradient, FCOORD rotation, BOOL8 testing_on)
Definition: topitch.cpp:73
short inT16
Definition: host.h:100
int inT32
Definition: host.h:102