textord/makerow.h

Go to the documentation of this file.
00001 
00019 #ifndef           MAKEROW_H
00020 #define           MAKEROW_H
00021 
00022 #include          "varable.h"
00023 #include          "ocrblock.h"
00024 #include          "tessclas.h"
00025 #include          "blobbox.h"
00026 #include          "statistc.h"
00027 #include          "notdll.h"
00028 
00033 enum OVERLAP_STATE
00034 {
00036   ASSIGN,
00038   REJECT,
00040   NEW_ROW
00041 };
00042 
00229 extern BOOL_VAR_H (textord_show_initial_rows, FALSE,
00230 "Display row accumulation");
00231 extern BOOL_VAR_H (textord_show_parallel_rows, FALSE,
00232 "Display page correlated rows");
00233 extern BOOL_VAR_H (textord_show_expanded_rows, FALSE,
00234 "Display rows after expanding");
00235 extern BOOL_VAR_H (textord_show_final_rows, FALSE,
00236 "Display rows after final fittin");
00237 extern BOOL_VAR_H (textord_show_final_blobs, FALSE,
00238 "Display blob bounds after pre-ass");
00239 extern BOOL_VAR_H (textord_test_landscape, FALSE, "Tests refer to land/port");
00240 extern BOOL_VAR_H (textord_parallel_baselines, TRUE,
00241 "Force parallel baselines");
00242 extern BOOL_VAR_H (textord_straight_baselines, FALSE,
00243 "Force straight baselines");
00244 extern BOOL_VAR_H (textord_quadratic_baselines, FALSE,
00245 "Use quadratic splines");
00246 extern BOOL_VAR_H (textord_old_baselines, TRUE, "Use old baseline algorithm");
00247 extern BOOL_VAR_H (textord_old_xheight, TRUE, "Use old xheight algorithm");
00248 extern BOOL_VAR_H (textord_fix_xheight_bug, TRUE, "Use spline baseline");
00249 extern BOOL_VAR_H (textord_fix_makerow_bug, TRUE,
00250 "Prevent multiple baselines");
00251 extern BOOL_VAR_H (textord_row_xheights, FALSE, "Use row height policy");
00252 extern BOOL_VAR_H (textord_block_xheights, TRUE, "Use block height policy");
00253 extern BOOL_VAR_H (textord_xheight_tweak, FALSE,
00254 "New min condition on height");
00255 extern BOOL_VAR_H (textord_cblob_blockocc, TRUE,
00256 "Use new projection for underlines");
00257 extern BOOL_VAR_H (textord_debug_xheights, FALSE, "Test xheight algorithms");
00258 extern INT_VAR_H (textord_test_x, 0, "coord of test pt");
00259 extern INT_VAR_H (textord_test_y, 0, "coord of test pt");
00260 extern INT_VAR_H (textord_min_blobs_in_row, 4,
00261 "Min blobs before gradient counted");
00262 extern INT_VAR_H (textord_spline_minblobs, 8,
00263 "Min blobs in each spline segment");
00264 extern INT_VAR_H (textord_spline_medianwin, 6,
00265 "Size of window for spline segmentation");
00266 extern INT_VAR_H (textord_min_xheight, 10, "Min credible pixel xheight");
00267 extern double_VAR_H (textord_spline_shift_fraction, 0.02,
00268 "Fraction of line spacing for quad");
00269 extern double_VAR_H (textord_spline_outlier_fraction, 0.1,
00270 "Fraction of line spacing for outlier");
00271 extern double_VAR_H (textord_skew_ile, 0.5, "Ile of gradients for page skew");
00272 extern double_VAR_H (textord_skew_lag, 0.75,
00273 "Lag for skew on row accumulation");
00274 extern double_VAR_H (textord_linespace_iqrlimit, 0.2,
00275 "Max iqr/median for linespace");
00276 extern double_VAR_H (textord_width_limit, 8,
00277 "Max width of blobs to make rows");
00278 extern double_VAR_H (textord_chop_width, 1.5, "Max width before chopping");
00279 extern double_VAR_H (textord_merge_desc, 0.25,
00280 "Fraction of linespace for desc drop");
00281 extern double_VAR_H (textord_merge_x, 0.5,
00282 "Fraction of linespace for x height");
00283 extern double_VAR_H (textord_merge_asc, 0.25,
00284 "Fraction of linespace for asc height");
00285 extern double_VAR_H (textord_minxh, 0.25,
00286 "fraction of linesize for min xheight");
00287 extern double_VAR_H (textord_min_linesize, 1.25,
00288 "* blob height for initial linesize");
00289 extern double_VAR_H (textord_excess_blobsize, 1.3,
00290 "New row made if blob makes row this big");
00291 extern double_VAR_H (textord_occupancy_threshold, 0.4,
00292 "Fraction of neighbourhood");
00293 extern double_VAR_H (textord_underline_width, 2.0,
00294 "Multiple of line_size for underline");
00295 extern double_VAR_H (textord_xheight_mode_fraction, 0.4,
00296 "Min pile height to make xheight");
00297 extern double_VAR_H (textord_ascheight_mode_fraction, 0.15,
00298 "Min pile height to make ascheight");
00299 extern double_VAR_H (textord_ascx_ratio_min, 1.2, "Min cap/xheight");
00300 extern double_VAR_H (textord_ascx_ratio_max, 1.7, "Max cap/xheight");
00301 extern double_VAR_H (textord_descx_ratio_min, 0.15, "Min desc/xheight");
00302 extern double_VAR_H (textord_descx_ratio_max, 0.6, "Max desc/xheight");
00303 extern double_VAR_H (textord_xheight_error_margin, 0.1, "Accepted variation");
00306 float make_rows(                             //make rows
00307                 ICOORD page_tr,              //top right
00308                 BLOCK_LIST *blocks,          //block list
00309                 TO_BLOCK_LIST *land_blocks,  //rotated for landscape
00310                 TO_BLOCK_LIST *port_blocks   //output list
00311                );
00312 void make_initial_textrows(                  //find lines
00313                            ICOORD page_tr,
00314                            TO_BLOCK *block,  //block to do
00315                            FCOORD rotation,  //for drawing
00316                            BOOL8 testing_on  //correct orientation
00317                           );
00318 void fit_lms_line(             //sort function
00319                   TO_ROW *row  //row to fit
00320                  );
00321 void compute_page_skew(                        //get average gradient
00322                        TO_BLOCK_LIST *blocks,  //list of blocks
00323                        float &page_m,          //average gradient
00324                        float &page_err         //average error
00325                       );
00326 void cleanup_rows(                   //find lines
00327                   ICOORD page_tr,    //top right
00328                   TO_BLOCK *block,   //block to do
00329                   float gradient,    //gradient to fit
00330                   FCOORD rotation,   //for drawing
00331                   INT32 block_edge,  //edge of block
00332                   BOOL8 testing_on   //correct orientation
00333                  );
00334 void delete_non_dropout_rows(                   //find lines
00335                              TO_BLOCK *block,   //block to do
00336                              float gradient,    //global skew
00337                              FCOORD rotation,   //deskew vector
00338                              INT32 block_edge,  //left edge
00339                              BOOL8 testing_on   //correct orientation
00340                             );
00341 BOOL8 find_best_dropout_row(                    //find neighbours
00342                             TO_ROW *row,        //row to test
00343                             INT32 distance,     //dropout dist
00344                             float dist_limit,   //threshold distance
00345                             INT32 line_index,   //index of row
00346                             TO_ROW_IT *row_it,  //current position
00347                             BOOL8 testing_on    //correct orientation
00348                            );
00349 BOX deskew_block_coords(                  //block box
00350                         TO_BLOCK *block,  //block to do
00351                         float gradient    //global skew
00352                        );
00353 void compute_line_occupation(                    //project blobs
00354                              TO_BLOCK *block,    //block to do
00355                              float gradient,     //global skew
00356                              INT32 min_y,        //min coord in block
00357                              INT32 max_y,        //in block
00358                              INT32 *occupation,  //output projection
00359                              INT32 *deltas       //derivative
00360                             );
00361 void compute_occupation_threshold(                    //project blobs
00362                                   INT32 low_window,   //below result point
00363                                   INT32 high_window,  //above result point
00364                                   INT32 line_count,   //array sizes
00365                                   INT32 *occupation,  //input projection
00366                                   INT32 *thresholds   //output thresholds
00367                                  );
00368 void compute_dropout_distances(                    //project blobs
00369                                INT32 *occupation,  //input projection
00370                                INT32 *thresholds,  //output thresholds
00371                                INT32 line_count    //array sizes
00372                               );
00373 void expand_rows(                   //find lines
00374                  ICOORD page_tr,    //top right
00375                  TO_BLOCK *block,   //block to do
00376                  float gradient,    //gradient to fit
00377                  FCOORD rotation,   //for drawing
00378                  INT32 block_edge,  //edge of block
00379                  BOOL8 testing_on   //correct orientation
00380                 );
00381 void adjust_row_limits(                 //tidy limits
00382                        TO_BLOCK *block  //block to do
00383                       );
00384 void compute_row_stats(                  //find lines
00385                        TO_BLOCK *block,  //block to do
00386                        BOOL8 testing_on  //correct orientation
00387                       );
00388 void compute_block_xheight(                  //find lines
00389                            TO_BLOCK *block,  //block to do
00390                            float gradient    //global skew
00391                           );
00392 float median_block_xheight(                  //find lines
00393                            TO_BLOCK *block,  //block to do
00394                            float gradient    //global skew
00395                           );
00396 INT32 compute_row_xheight(                   //find lines
00397                           TO_ROW *row,       //row to do
00398                           INT32 min_height,  //min xheight
00399                           INT32 max_height,  //max xheight
00400                           float gradient     //global skew
00401                          );
00402 INT32 compute_row_descdrop(                //find lines
00403                            TO_ROW *row,    //row to do
00404                            float gradient  //global skew
00405                           );
00406 INT32 compute_height_modes(                   //find lines
00407                            STATS *heights,    //stats to search
00408                            INT32 min_height,  //bottom of range
00409                            INT32 max_height,  //top of range
00410                            INT32 *modes,      //output array
00411                            INT32 maxmodes     //size of modes
00412                           );
00413 void correct_row_xheight(                //fix bad values
00414                          TO_ROW *row,    //row to fix
00415                          float xheight,  //average values
00416                          float ascrise,
00417                          float descdrop);
00418 void separate_underlines(                  //make rough chars
00419                          TO_BLOCK *block,  //block to do
00420                          float gradient,   //skew angle
00421                          FCOORD rotation,  //inverse landscape
00422                          BOOL8 testing_on  //correct orientation
00423                         );
00424 void pre_associate_blobs(                  //make rough chars
00425                          ICOORD page_tr,   //top right
00426                          TO_BLOCK *block,  //block to do
00427                          FCOORD rotation,  //inverse landscape
00428                          BOOL8 testing_on  //correct orientation
00429                         );
00430 void fit_parallel_rows(                   //find lines
00431                        TO_BLOCK *block,   //block to do
00432                        float gradient,    //gradient to fit
00433                        FCOORD rotation,   //for drawing
00434                        INT32 block_edge,  //edge of block
00435                        BOOL8 testing_on   //correct orientation
00436                       );
00437 void fit_parallel_lms(                 //sort function
00438                       float gradient,  //forced gradient
00439                       TO_ROW *row      //row to fit
00440                      );
00441 void make_spline_rows(                   //find lines
00442                       TO_BLOCK *block,   //block to do
00443                       float gradient,    //gradient to fit
00444                       FCOORD rotation,   //for drawing
00445                       INT32 block_edge,  //edge of block
00446                       BOOL8 testing_on   //correct orientation
00447                      );
00448 void make_baseline_spline(                 //sort function
00449                           TO_ROW *row,     //row to fit
00450                           TO_BLOCK *block  //block it came from
00451                          );
00452 BOOL8 segment_baseline (         //split baseline
00453 TO_ROW * row,                    //row to fit
00454 TO_BLOCK * block,                //block it came from
00455 INT32 & segments,                //no fo segments
00456 INT32 xstarts[]                  //coords of segments
00457 );
00458 double *linear_spline_baseline ( //split baseline
00459 TO_ROW * row,                    //row to fit
00460 TO_BLOCK * block,                //block it came from
00461 INT32 & segments,                //no fo segments
00462 INT32 xstarts[]                  //coords of segments
00463 );
00464 void assign_blobs_to_rows(                      //find lines
00465                           TO_BLOCK *block,      //block to do
00466                           float *gradient,      //block skew
00467                           int pass,             //identification
00468                           BOOL8 reject_misses,  //chuck big ones out
00469                           BOOL8 make_new_rows,  //add rows for unmatched
00470                           BOOL8 drawing_skew    //draw smoothed skew
00471                          );
00472                                  //find best row
00473 OVERLAP_STATE most_overlapping_row(TO_ROW_IT *row_it,  //iterator
00474                                    TO_ROW *&best_row,  //output row
00475                                    float top,          //top of blob
00476                                    float bottom,       //bottom of blob
00477                                    float rowsize,      //max row size
00478                                    BOOL8 testing_blob  //test stuff
00479                                   );
00480 int blob_x_order(                    //sort function
00481                  const void *item1,  //items to compare
00482                  const void *item2);
00483 int row_y_order(                    //sort function
00484                 const void *item1,  //items to compare
00485                 const void *item2);
00486 int row_spacing_order(                    //sort function
00487                       const void *item1,  //items to compare
00488                       const void *item2);
00489 #endif

Generated on Wed Feb 28 19:49:11 2007 for Tesseract by  doxygen 1.5.1