00001
00019 #ifndef TOPITCH_H
00020 #define TOPITCH_H
00021
00022 #include "blobbox.h"
00023 #include "notdll.h"
00024
00067 extern BOOL_VAR_H (textord_debug_pitch_test, FALSE,
00068 "Debug on fixed pitch test");
00069 extern BOOL_VAR_H (textord_debug_pitch_metric, FALSE,
00070 "Write full metric stuff");
00071 extern BOOL_VAR_H (textord_show_row_cuts, FALSE, "Draw row-level cuts");
00072 extern BOOL_VAR_H (textord_show_page_cuts, FALSE, "Draw page-level cuts");
00073 extern BOOL_VAR_H (textord_pitch_cheat, FALSE,
00074 "Use correct answer for fixed/prop");
00075 extern BOOL_VAR_H (textord_blockndoc_fixed, TRUE,
00076 "Attempt whole doc/block fixed pitch");
00077 extern BOOL_VAR_H (textord_fast_pitch_test, FALSE,
00078 "Do even faster pitch algorithm");
00079 extern double_VAR_H (textord_projection_scale, 0.125,
00080 "Ding rate for mid-cuts");
00081 extern double_VAR_H (textord_balance_factor, 2.0,
00082 "Ding rate for unbalanced char cells");
00083 extern double_VAR_H (textord_repch_width_variance, 0.2,
00084 "Max width change of gap/blob");
00087 void compute_fixed_pitch(
00088 ICOORD page_tr,
00089 TO_BLOCK_LIST *port_blocks,
00090 float gradient,
00091 FCOORD rotation,
00092 BOOL8 testing_on
00093 );
00094 void fix_row_pitch(
00095 TO_ROW *bad_row,
00096 TO_BLOCK *bad_block,
00097 TO_BLOCK_LIST *blocks,
00098 INT32 row_target,
00099 INT32 block_target
00100 );
00101 void compute_block_pitch(
00102 TO_BLOCK *block,
00103 FCOORD rotation,
00104 INT32 block_index,
00105 BOOL8 testing_on
00106 );
00107 BOOL8 compute_rows_pitch(
00108 TO_BLOCK *block,
00109 INT32 block_index,
00110 BOOL8 testing_on
00111 );
00112 BOOL8 try_doc_fixed(
00113 ICOORD page_tr,
00114 TO_BLOCK_LIST *port_blocks,
00115 float gradient
00116 );
00117 BOOL8 try_block_fixed(
00118 TO_BLOCK *block,
00119 INT32 block_index
00120 );
00121 BOOL8 try_rows_fixed(
00122 TO_BLOCK *block,
00123 INT32 block_index,
00124 BOOL8 testing_on
00125 );
00126 void print_block_counts(
00127 TO_BLOCK *block,
00128 INT32 block_index
00129 );
00130 void count_block_votes(
00131 TO_BLOCK *block,
00132 INT32 &def_fixed,
00133 INT32 &def_prop,
00134 INT32 &maybe_fixed,
00135 INT32 &maybe_prop,
00136 INT32 &corr_fixed,
00137 INT32 &corr_prop,
00138 INT32 &dunno);
00139 BOOL8 row_pitch_stats(
00140 TO_ROW *row,
00141 INT32 maxwidth,
00142 BOOL8 testing_on
00143 );
00144 BOOL8 find_row_pitch(
00145 TO_ROW *row,
00146 INT32 maxwidth,
00147 INT32 dm_gap,
00148 TO_BLOCK *block,
00149 INT32 block_index,
00150 INT32 row_index,
00151 BOOL8 testing_on
00152 );
00153 BOOL8 fixed_pitch_row(
00154 TO_ROW *row,
00155 INT32 block_index
00156 );
00157 BOOL8 count_pitch_stats(
00158 TO_ROW *row,
00159 STATS *gap_stats,
00160 STATS *pitch_stats,
00161 float initial_pitch,
00162 float min_space,
00163 BOOL8 ignore_outsize,
00164 BOOL8 split_outsize,
00165 INT32 dm_gap
00166 );
00167 float tune_row_pitch(
00168 TO_ROW *row,
00169 STATS *projection,
00170 INT16 projection_left,
00171 INT16 projection_right,
00172 float space_size,
00173 float &initial_pitch,
00174 float &best_sp_sd,
00175 INT16 &best_mid_cuts,
00176 ICOORDELT_LIST *best_cells,
00177 BOOL8 testing_on
00178 );
00179 float tune_row_pitch2(
00180 TO_ROW *row,
00181 STATS *projection,
00182 INT16 projection_left,
00183 INT16 projection_right,
00184 float space_size,
00185 float &initial_pitch,
00186 float &best_sp_sd,
00187 INT16 &best_mid_cuts,
00188 ICOORDELT_LIST *best_cells,
00189 BOOL8 testing_on
00190 );
00191 float compute_pitch_sd (
00192 TO_ROW * row,
00193 STATS * projection,
00194 INT16 projection_left,
00195 INT16 projection_right,
00196 float space_size,
00197 float initial_pitch,
00198 float &sp_sd,
00199 INT16 & mid_cuts,
00200 ICOORDELT_LIST * row_cells,
00201 BOOL8 testing_on,
00202 INT16 start = 0,
00203 INT16 end = 0
00204 );
00205 float compute_pitch_sd2 (
00206 TO_ROW * row,
00207 STATS * projection,
00208 INT16 projection_left,
00209 INT16 projection_right,
00210 float initial_pitch,
00211 INT16 & occupation,
00212 INT16 & mid_cuts,
00213 ICOORDELT_LIST * row_cells,
00214 BOOL8 testing_on,
00215 INT16 start = 0,
00216 INT16 end = 0
00217 );
00218 void print_pitch_sd(
00219 TO_ROW *row,
00220 STATS *projection,
00221 INT16 projection_left,
00222 INT16 projection_right,
00223 float space_size,
00224 float initial_pitch
00225 );
00226 int sort_floats2(
00227 const void *arg1,
00228 const void *arg2);
00229 void find_repeated_chars(
00230 TO_BLOCK *block,
00231 BOOL8 testing_on
00232 );
00233 void plot_fp_word(
00234 TO_BLOCK *block,
00235 float pitch,
00236 float nonspace
00237 );
00238 #endif