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