TO_ROW Class Reference

#include <blobbox.h>

Inheritance diagram for TO_ROW:

ELIST2_LINK List of all members.

Detailed Description

Class which converts blobs to rows.

Definition at line 167 of file blobbox.h.

Public Member Functions

Public Attributes

Private Attributes


Constructor & Destructor Documentation

TO_ROW::TO_ROW (  )  [inline]

Definition at line 170 of file blobbox.h.

00170              {
00171     }                            //empty

TO_ROW::TO_ROW ( BLOBNBOX blob,
float  top,
float  bottom,
float  row_size 
)

Constructor to make a row from a blob.

Definition at line 428 of file blobbox.cpp.

References blobs, y_max, and y_min.

00433  :y_min (bottom), y_max (top), initial_y_min (bottom) {
00434   float diff;                    //in size
00435   BLOBNBOX_IT it = &blobs;       //list of blobs
00436 
00437   it.add_to_end (blob);
00438   diff = top - bottom - row_size;
00439   if (diff > 0) {
00440     y_max -= diff / 2;
00441     y_min += diff / 2;
00442   }
00443                                  //very small object
00444   else if ((top - bottom) * 3 < row_size) {
00445     diff = row_size / 3 + bottom - top;
00446     y_max += diff / 2;
00447     y_min -= diff / 2;
00448   }
00449 }


Member Function Documentation

void TO_ROW::add_blob ( BLOBNBOX blob,
float  top,
float  bottom,
float  row_size 
)

Add the blob to the end of the row.

Definition at line 455 of file blobbox.cpp.

References blobs, y_max, and y_min.

Referenced by assign_blobs_to_rows().

00460                        {
00461   float allowed;                 //allowed expansion
00462   float available;               //expansion
00463   BLOBNBOX_IT it = &blobs;       //list of blobs
00464 
00465   it.add_to_end (blob);
00466   allowed = row_size + y_min - y_max;
00467   if (allowed > 0) {
00468     available = top > y_max ? top - y_max : 0;
00469     if (bottom < y_min)
00470                                  //total available
00471         available += y_min - bottom;
00472     if (available > 0) {
00473       available += available;    //do it gradually
00474       if (available < allowed)
00475         available = allowed;
00476       if (bottom < y_min)
00477         y_min -= (y_min - bottom) * allowed / available;
00478       if (top > y_max)
00479         y_max += (top - y_max) * allowed / available;
00480     }
00481   }
00482 }

float TO_ROW::believability (  )  const [inline]

Definition at line 205 of file blobbox.h.

References credibility.

Referenced by find_best_dropout_row().

00205                                 {  // baseline goodness
00206       return credibility;
00207     }

BLOBNBOX_LIST* TO_ROW::blob_list (  )  [inline]

Definition at line 219 of file blobbox.h.

References blobs.

Referenced by block_spacing_stats(), compute_line_occupation(), compute_page_skew(), compute_pitch_sd(), compute_pitch_sd2(), compute_row_descdrop(), compute_row_xheight(), compute_vertical_projection(), count_pitch_stats(), deskew_block_coords(), draw_meanlines(), expand_rows(), find_repeated_chars(), find_textlines(), fit_lms_line(), fit_parallel_lms(), GAPMAP::GAPMAP(), get_blob_coords(), isolated_row_stats(), linear_spline_baseline(), make_baseline_spline(), make_old_baselines(), make_prop_words(), make_real_words(), median_block_xheight(), most_overlapping_row(), plot_fp_cells2(), plot_parallel_row(), plot_row_cells(), plot_to_row(), plot_word_decisions(), print_pitch_sd(), row_pitch_stats(), row_spacing_stats(), row_words(), row_words2(), segment_baseline(), and separate_underlines().

00219                                {  // get list of blobs
00220       return &blobs;
00221     }

void TO_ROW::compute_vertical_projection (  ) 

Compute the vertical projection of a TO_ROW from its blobs.

Definition at line 512 of file blobbox.cpp.

References blob_list(), BOX::left(), NULL, projection, projection_left, PROJECTION_MARGIN, projection_right, BOX::right(), STATS::set_range(), vertical_blob_projection(), and vertical_cblob_projection().

Referenced by compute_rows_pitch().

00512                                          {  //project whole row
00513   BOX row_box;                   //bound of row
00514   BLOBNBOX *blob;                //current blob
00515   BOX blob_box;                  //bounding box
00516   BLOBNBOX_IT blob_it = blob_list ();
00517 
00518   if (blob_it.empty ())
00519     return;
00520   row_box = blob_it.data ()->bounding_box ();
00521   for (blob_it.mark_cycle_pt (); !blob_it.cycled_list (); blob_it.forward ())
00522     row_box += blob_it.data ()->bounding_box ();
00523 
00524   projection.set_range (row_box.left () - PROJECTION_MARGIN,
00525     row_box.right () + PROJECTION_MARGIN);
00526   projection_left = row_box.left () - PROJECTION_MARGIN;
00527   projection_right = row_box.right () + PROJECTION_MARGIN;
00528   for (blob_it.mark_cycle_pt (); !blob_it.cycled_list (); blob_it.forward ()) {
00529     blob = blob_it.data ();
00530     if (blob->blob () != NULL)
00531       vertical_blob_projection (blob->blob (), &projection);
00532     else if (blob->cblob () != NULL)
00533       vertical_cblob_projection (blob->cblob (), &projection);
00534   }
00535 }

float TO_ROW::initial_min_y (  )  const [inline]

Definition at line 187 of file blobbox.h.

References initial_y_min.

Referenced by assign_blobs_to_rows().

00187                                 {
00188       return initial_y_min;
00189     }

void TO_ROW::insert_blob ( BLOBNBOX blob  ) 

Add the blob to the row in the correct position.

Definition at line 488 of file blobbox.cpp.

References blobs.

Referenced by restore_underlined_blobs().

00490                           {
00491   BLOBNBOX_IT it = &blobs;       //list of blobs
00492 
00493   if (it.empty ())
00494     it.add_before_then_move (blob);
00495   else {
00496     it.mark_cycle_pt ();
00497     while (!it.cycled_list ()
00498       && it.data ()->bounding_box ().left () <=
00499       blob->bounding_box ().left ())
00500       it.forward ();
00501     if (it.cycled_list ())
00502       it.add_to_end (blob);
00503     else
00504       it.add_before_stay_put (blob);
00505   }
00506 }

float TO_ROW::intercept (  )  const [inline]

Definition at line 208 of file blobbox.h.

References y_origin.

Referenced by adjust_row_limits(), compute_pitch_sd(), compute_pitch_sd2(), compute_row_stats(), delete_non_dropout_rows(), expand_rows(), find_best_dropout_row(), row_words(), row_words2(), separate_underlines(), set_row_spaces(), and try_doc_fixed().

00208                             {  // real parallel_c
00209       return y_origin;
00210     }

float TO_ROW::line_c (  )  const [inline]

Definition at line 193 of file blobbox.h.

References c.

Referenced by dot_of_i(), make_prop_words(), make_rep_words(), plot_to_row(), and segment_baseline().

00193                          {
00194       return c;
00195     }

float TO_ROW::line_error (  )  const [inline]

Definition at line 196 of file blobbox.h.

References error.

Referenced by compute_page_skew().

00196                              {
00197       return error;
00198     }

float TO_ROW::line_m (  )  const [inline]

Definition at line 190 of file blobbox.h.

References m.

Referenced by compute_page_skew(), dot_of_i(), find_textlines(), make_prop_words(), make_rep_words(), plot_to_row(), and segment_baseline().

00190                          {  // access to line fit
00191       return m;
00192     }

float TO_ROW::max_y (  )  const [inline]

Definition at line 178 of file blobbox.h.

References y_max.

Referenced by adjust_row_limits(), assign_blobs_to_rows(), expand_rows(), most_overlapping_row(), and plot_parallel_row().

00178                         {  // access function
00179       return y_max;
00180     }

float TO_ROW::mean_y (  )  const [inline]

Definition at line 184 of file blobbox.h.

References y_max, and y_min.

00184                          {
00185       return (y_min + y_max) / 2.0f;
00186     }

float TO_ROW::min_y (  )  const [inline]

Definition at line 181 of file blobbox.h.

References y_min.

Referenced by adjust_row_limits(), assign_blobs_to_rows(), expand_rows(), most_overlapping_row(), and plot_parallel_row().

00181                         {
00182       return y_min;
00183     }

TO_ROW::NEWDELETE2 ( TO_ROW   ) 

float TO_ROW::parallel_c (  )  const [inline]

Definition at line 199 of file blobbox.h.

References para_c.

Referenced by compute_row_descdrop(), compute_row_stats(), compute_row_xheight(), draw_meanlines(), find_best_dropout_row(), median_block_xheight(), plot_parallel_row(), plot_to_row(), and row_y_order().

00199                              {
00200       return para_c;
00201     }

float TO_ROW::parallel_error (  )  const [inline]

Definition at line 202 of file blobbox.h.

References para_error.

00202                                  {
00203       return para_error;
00204     }

void TO_ROW::set_limits ( float  new_min,
float  new_max 
) [inline]

Definition at line 242 of file blobbox.h.

References y_max, and y_min.

Referenced by adjust_row_limits(), and expand_rows().

00244                                    {  //top of row
00245       y_min = new_min;
00246       y_max = new_max;
00247     }

void TO_ROW::set_line ( float  new_m,
float  new_c,
float  new_error 
) [inline]

Definition at line 223 of file blobbox.h.

References c, error, and m.

Referenced by fit_lms_line(), and fit_parallel_lms().

00226                                    {
00227       m = new_m;
00228       c = new_c;
00229       error = new_error;
00230     }

void TO_ROW::set_parallel_line ( float  gradient,
float  new_c,
float  new_error 
) [inline]

Definition at line 231 of file blobbox.h.

References blobs, credibility, para_c, para_error, and y_origin.

Referenced by fit_parallel_lms().

00234                                             {
00235       para_c = new_c;
00236       para_error = new_error;
00237       credibility =
00238         (float) (blobs.length () - textord_error_weight * new_error);
00239       y_origin = (float) (new_c / sqrt (1 + gradient * gradient));
00240       //real intercept
00241     }


Member Data Documentation

BOOL8 TO_ROW::all_caps

Had no ascenders.

Definition at line 252 of file blobbox.h.

Referenced by correct_row_xheight(), fix_row_pitch(), fixed_pitch_row(), and print_pitch_sd().

float TO_ROW::ascrise

Ascenders.

Definition at line 276 of file blobbox.h.

Referenced by compute_block_xheight(), compute_row_xheight(), correct_row_xheight(), correlate_with_stats(), find_textlines(), fix_row_pitch(), most_overlapping_row(), old_first_xheight(), pick_x_height(), and ROW::ROW().

QSPLINE TO_ROW::baseline

Curved baseline.

Definition at line 294 of file blobbox.h.

Referenced by compute_row_xheight(), correlate_neighbours(), find_lesser_parts(), find_textlines(), make_old_baselines(), most_overlapping_row(), reduced_box_for_blob(), restore_underlined_blobs(), ROW::ROW(), suspected_punct_blob(), and try_doc_fixed().

BLOBNBOX_LIST TO_ROW::blobs [private]

Blobs in row.

Definition at line 300 of file blobbox.h.

Referenced by add_blob(), blob_list(), insert_blob(), set_parallel_line(), and TO_ROW().

float TO_ROW::c [private]

Definition at line 307 of file blobbox.h.

Referenced by line_c(), and set_line().

ICOORDELT_LIST TO_ROW::char_cells

Fixed pitch cells.

Definition at line 292 of file blobbox.h.

Referenced by fix_row_pitch(), fixed_pitch_row(), and try_doc_fixed().

float TO_ROW::credibility [private]

Baseline believability.

Definition at line 316 of file blobbox.h.

Referenced by believability(), and set_parallel_line().

float TO_ROW::descdrop

Descenders.

Definition at line 278 of file blobbox.h.

Referenced by compute_block_xheight(), compute_row_xheight(), correct_row_xheight(), correlate_with_stats(), find_lesser_parts(), find_textlines(), most_overlapping_row(), and ROW::ROW().

float TO_ROW::error [private]

Line error.

Definition at line 309 of file blobbox.h.

Referenced by line_error(), and set_line().

float TO_ROW::fixed_pitch

Pitch or 0.

Definition at line 262 of file blobbox.h.

Referenced by find_row_pitch(), fix_row_pitch(), fixed_pitch_row(), print_pitch_sd(), set_row_spaces(), to_spacing(), try_doc_fixed(), and try_rows_fixed().

float TO_ROW::fp_nonsp

Nonsp if fixed pitch.

Definition at line 266 of file blobbox.h.

Referenced by find_row_pitch(), fixed_pitch_row(), and row_pitch_stats().

float TO_ROW::fp_space

Sp if fixed pitch.

Definition at line 264 of file blobbox.h.

Referenced by find_row_pitch(), and row_pitch_stats().

float TO_ROW::initial_y_min [private]

Definition at line 305 of file blobbox.h.

Referenced by initial_min_y().

float TO_ROW::kern_size

Average non-space.

Definition at line 286 of file blobbox.h.

Referenced by fix_row_pitch(), improve_row_threshold(), isolated_row_stats(), make_a_word_break(), make_prop_words(), old_to_method(), row_words(), row_words2(), set_row_spaces(), and try_rows_fixed().

float TO_ROW::m [private]

Line spec.

Definition at line 307 of file blobbox.h.

Referenced by line_m(), and set_line().

INT32 TO_ROW::max_nonspace

Max size of non-space.

Definition at line 282 of file blobbox.h.

Referenced by fix_row_pitch(), make_a_word_break(), plot_fp_word(), plot_word_decisions(), row_words(), row_words2(), and set_row_spaces().

INT32 TO_ROW::min_space

Min size for real space.

Definition at line 280 of file blobbox.h.

Referenced by fix_row_pitch(), make_a_word_break(), plot_fp_word(), plot_word_decisions(), row_words(), row_words2(), and set_row_spaces().

float TO_ROW::para_c [private]

Constrained fit.

Definition at line 311 of file blobbox.h.

Referenced by parallel_c(), and set_parallel_line().

float TO_ROW::para_error [private]

Definition at line 312 of file blobbox.h.

Referenced by parallel_error(), and set_parallel_line().

PITCH_TYPE TO_ROW::pitch_decision

How strong is decision.

Definition at line 260 of file blobbox.h.

Referenced by block_spacing_stats(), count_block_votes(), fix_row_pitch(), fixed_pitch_row(), make_real_words(), and to_spacing().

float TO_ROW::pr_nonsp

Non sp if prop.

Definition at line 270 of file blobbox.h.

Referenced by row_pitch_stats(), set_row_spaces(), and try_rows_fixed().

float TO_ROW::pr_space

Sp if prop.

Definition at line 268 of file blobbox.h.

Referenced by row_pitch_stats(), set_row_spaces(), and try_rows_fixed().

STATS TO_ROW::projection

Vertical projection.

Definition at line 296 of file blobbox.h.

Referenced by compute_vertical_projection(), fix_row_pitch(), fixed_pitch_row(), plot_word_decisions(), and try_doc_fixed().

INT16 TO_ROW::projection_left

Start of projection.

Definition at line 256 of file blobbox.h.

Referenced by compute_vertical_projection(), fixed_pitch_row(), plot_word_decisions(), and try_doc_fixed().

INT16 TO_ROW::projection_right

Start of projection.

Definition at line 258 of file blobbox.h.

Referenced by compute_vertical_projection(), fixed_pitch_row(), plot_word_decisions(), and try_doc_fixed().

WERD_LIST TO_ROW::rep_words

Repeated chars.

Definition at line 290 of file blobbox.h.

Referenced by find_repeated_chars(), make_prop_words(), make_real_words(), and make_rep_words().

float TO_ROW::space_size

Average space.

Definition at line 288 of file blobbox.h.

Referenced by fix_row_pitch(), improve_row_threshold(), isolated_row_stats(), make_a_word_break(), make_prop_words(), old_to_method(), row_words(), row_words2(), set_row_spaces(), and try_rows_fixed().

INT32 TO_ROW::space_threshold

Space vs nonspace.

Definition at line 284 of file blobbox.h.

Referenced by fix_row_pitch(), improve_row_threshold(), isolated_row_stats(), make_a_word_break(), old_to_method(), plot_fp_word(), plot_word_decisions(), row_words(), row_words2(), and set_row_spaces().

float TO_ROW::spacing

To 'next' row.

Definition at line 272 of file blobbox.h.

Referenced by compute_row_stats(), and row_spacing_order().

BOOL8 TO_ROW::used_dm_model

In guessing pitch.

Definition at line 254 of file blobbox.h.

Referenced by fixed_pitch_row().

float TO_ROW::xheight

Height of line.

Definition at line 274 of file blobbox.h.

Referenced by block_spacing_stats(), compute_block_xheight(), compute_pitch_sd(), compute_pitch_sd2(), compute_row_descdrop(), compute_row_xheight(), compute_rows_pitch(), correct_row_xheight(), correlate_neighbours(), correlate_with_stats(), draw_meanlines(), find_lesser_parts(), find_row_pitch(), find_textlines(), fix_row_pitch(), GAPMAP::GAPMAP(), ignore_big_gap(), isolated_row_stats(), make_a_word_break(), make_first_xheight(), make_old_baselines(), make_rep_words(), most_overlapping_row(), narrow_blob(), old_first_xheight(), pick_x_height(), plot_word_decisions(), print_pitch_sd(), reduced_box_for_blob(), reduced_box_next(), restore_underlined_blobs(), ROW::ROW(), row_pitch_stats(), row_spacing_stats(), row_words(), suspected_punct_blob(), try_rows_fixed(), and wide_blob().

float TO_ROW::y_max [private]

Coords.

Definition at line 304 of file blobbox.h.

Referenced by add_blob(), max_y(), mean_y(), set_limits(), and TO_ROW().

float TO_ROW::y_min [private]

Coords.

Definition at line 302 of file blobbox.h.

Referenced by add_blob(), mean_y(), min_y(), set_limits(), and TO_ROW().

float TO_ROW::y_origin [private]

Rotated para_c;.

Definition at line 314 of file blobbox.h.

Referenced by intercept(), and set_parallel_line().


The documentation for this class was generated from the following files:
Generated on Wed Feb 28 19:49:34 2007 for Tesseract by  doxygen 1.5.1