tesseract v5.3.3.20231005
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 {
25
26class Tesseract;
27
36
37void compute_fixed_pitch(ICOORD page_tr, // top right
38 TO_BLOCK_LIST *port_blocks, // input list
39 float gradient, // page skew
40 FCOORD rotation, // for drawing
41 bool testing_on); // correct orientation
42void fix_row_pitch( // get some value
43 TO_ROW *bad_row, // row to fix
44 TO_BLOCK *bad_block, // block of bad_row
45 TO_BLOCK_LIST *blocks, // blocks to scan
46 int32_t row_target, // number of row
47 int32_t block_target // number of block
48);
49void compute_block_pitch(TO_BLOCK *block, // input list
50 FCOORD rotation, // for drawing
51 int32_t block_index, // block number
52 bool testing_on); // correct orientation
53bool compute_rows_pitch( // find line stats
54 TO_BLOCK *block, // block to do
55 int32_t block_index, // block number
56 bool testing_on // correct orientation
57);
58bool try_doc_fixed( // determine pitch
59 ICOORD page_tr, // top right
60 TO_BLOCK_LIST *port_blocks, // input list
61 float gradient // page skew
62);
63bool try_block_fixed( // find line stats
64 TO_BLOCK *block, // block to do
65 int32_t block_index // block number
66);
67bool try_rows_fixed( // find line stats
68 TO_BLOCK *block, // block to do
69 int32_t block_index, // block number
70 bool testing_on // correct orientation
71);
72void print_block_counts( // find line stats
73 TO_BLOCK *block, // block to do
74 int32_t block_index // block number
75);
76void count_block_votes( // find line stats
77 TO_BLOCK *block, // block to do
78 int32_t &def_fixed, // add to counts
79 int32_t &def_prop, int32_t &maybe_fixed, int32_t &maybe_prop, int32_t &corr_fixed,
80 int32_t &corr_prop, int32_t &dunno);
81bool row_pitch_stats( // find line stats
82 TO_ROW *row, // current row
83 int32_t maxwidth, // of spaces
84 bool testing_on // correct orientation
85);
86bool find_row_pitch( // find lines
87 TO_ROW *row, // row to do
88 int32_t maxwidth, // max permitted space
89 int32_t dm_gap, // ignorable gaps
90 TO_BLOCK *block, // block of row
91 int32_t block_index, // block_number
92 int32_t row_index, // number of row
93 bool testing_on // correct orientation
94);
95bool fixed_pitch_row( // find lines
96 TO_ROW *row, // row to do
97 BLOCK *block,
98 int32_t block_index // block_number
99);
100bool count_pitch_stats( // find lines
101 TO_ROW *row, // row to do
102 STATS *gap_stats, // blob gaps
103 STATS *pitch_stats, // centre-centre stats
104 float initial_pitch, // guess at pitch
105 float min_space, // estimate space size
106 bool ignore_outsize, // discard big objects
107 bool split_outsize, // split big objects
108 int32_t dm_gap // ignorable gaps
109);
110float tune_row_pitch( // find fp cells
111 TO_ROW *row, // row to do
112 STATS *projection, // vertical projection
113 int16_t projection_left, // edge of projection
114 int16_t projection_right, // edge of projection
115 float space_size, // size of blank
116 float &initial_pitch, // guess at pitch
117 float &best_sp_sd, // space sd
118 int16_t &best_mid_cuts, // no of cheap cuts
119 ICOORDELT_LIST *best_cells, // row cells
120 bool testing_on // individual words
121);
122float tune_row_pitch2( // find fp cells
123 TO_ROW *row, // row to do
124 STATS *projection, // vertical projection
125 int16_t projection_left, // edge of projection
126 int16_t 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_t &best_mid_cuts, // no of cheap cuts
131 ICOORDELT_LIST *best_cells, // row cells
132 bool testing_on // individual words
133);
134float compute_pitch_sd( // find fp cells
135 TO_ROW *row, // row to do
136 STATS *projection, // vertical projection
137 int16_t projection_left, // edge
138 int16_t projection_right, // edge
139 float space_size, // size of blank
140 float initial_pitch, // guess at pitch
141 float &sp_sd, // space sd
142 int16_t &mid_cuts, // no of free cuts
143 ICOORDELT_LIST *row_cells, // list of chop pts
144 bool testing_on, // individual words
145 int16_t start = 0, // start of good range
146 int16_t end = 0 // end of good range
147);
148float compute_pitch_sd2( // find fp cells
149 TO_ROW *row, // row to do
150 STATS *projection, // vertical projection
151 int16_t projection_left, // edge
152 int16_t projection_right, // edge
153 float initial_pitch, // guess at pitch
154 int16_t &occupation, // no of occupied cells
155 int16_t &mid_cuts, // no of free cuts
156 ICOORDELT_LIST *row_cells, // list of chop pts
157 bool testing_on, // individual words
158 int16_t start = 0, // start of good range
159 int16_t end = 0 // end of good range
160);
161void print_pitch_sd( // find fp cells
162 TO_ROW *row, // row to do
163 STATS *projection, // vertical projection
164 int16_t projection_left, // edges //size of blank
165 int16_t projection_right, float space_size,
166 float initial_pitch // guess at pitch
167);
168void find_repeated_chars(TO_BLOCK *block, // Block to search.
169 bool testing_on); // Debug mode.
170void plot_fp_word( // draw block of words
171 TO_BLOCK *block, // block to draw
172 float pitch, // pitch to draw with
173 float nonspace // for space threshold
174);
175
176} // namespace tesseract
177
178#endif
void compute_fixed_pitch(ICOORD page_tr, TO_BLOCK_LIST *port_blocks, float gradient, FCOORD rotation, bool testing_on)
Definition: topitch.cpp:75
bool try_block_fixed(TO_BLOCK *block, int32_t block_index)
Definition: topitch.cpp:502
void compute_block_pitch(TO_BLOCK *block, FCOORD rotation, int32_t block_index, bool testing_on)
Definition: topitch.cpp:293
bool fixed_pitch_row(TO_ROW *row, BLOCK *block, int32_t block_index)
Definition: topitch.cpp:931
void plot_fp_word(TO_BLOCK *block, float pitch, float nonspace)
Definition: topitch.cpp:1730
double_VAR_H(classify_min_slope)
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, int16_t end)
Definition: topitch.cpp:1446
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, int16_t end)
Definition: topitch.cpp:1289
bool try_rows_fixed(TO_BLOCK *block, int32_t block_index, bool testing_on)
Definition: topitch.cpp:515
void find_repeated_chars(TO_BLOCK *block, bool testing_on)
Definition: topitch.cpp:1660
double textord_projection_scale
Definition: topitch.cpp:49
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:1535
bool textord_blockndoc_fixed
Definition: topitch.cpp:48
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:1008
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:784
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:144
bool textord_debug_pitch_metric
Definition: topitch.cpp:45
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:1196
void print_block_counts(TO_BLOCK *block, int32_t block_index)
Definition: topitch.cpp:575
BOOL_VAR_H(wordrec_display_splits)
bool textord_debug_pitch_test
Definition: topitch.cpp:42
bool row_pitch_stats(TO_ROW *row, int32_t maxwidth, bool testing_on)
Definition: topitch.cpp:648
double textord_balance_factor
Definition: topitch.cpp:50
bool textord_show_row_cuts
Definition: topitch.cpp:46
bool try_doc_fixed(ICOORD page_tr, TO_BLOCK_LIST *port_blocks, float gradient)
Definition: topitch.cpp:371
bool textord_fast_pitch_test
Definition: topitch.cpp:44
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:1097
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:606
bool textord_show_page_cuts
Definition: topitch.cpp:47
bool compute_rows_pitch(TO_BLOCK *block, int32_t block_index, bool testing_on)
Definition: topitch.cpp:330
integer coordinate
Definition: points.h:36