#include <ocrrow.h>
Inheritance diagram for ROW:
Definition at line 33 of file ocrrow.h.
ROW::ROW | ( | INT32 | spline_size, | |
INT32 * | xstarts, | |||
double * | coeffs, | |||
float | x_height, | |||
float | ascenders, | |||
float | descenders, | |||
INT16 | kern, | |||
INT16 | space | |||
) |
Constructor to build a ROW.
Only the stats stuff are given here. The words are added directly.
Definition at line 56 of file ocrrow.cpp.
References TO_ROW::ascrise, ascrise, TO_ROW::baseline, baseline, TO_ROW::descdrop, descdrop, kerning, spacing, TO_ROW::xheight, and xheight.
00060 { 00061 kerning = kern; //just store stuff 00062 spacing = space; 00063 xheight = to_row->xheight; 00064 ascrise = to_row->ascrise; 00065 descdrop = to_row->descdrop; 00066 baseline = to_row->baseline; 00067 }
float ROW::ascenders | ( | ) | const [inline] |
Definition at line 71 of file ocrrow.h.
References ascrise.
Referenced by make_tess_row(), and write_shm_text().
00071 { //return size 00072 return ascrise; 00073 }
float ROW::base_line | ( | float | xpos | ) | const [inline] |
Definition at line 57 of file ocrrow.h.
References baseline, and QSPLINE::y().
Referenced by WERD::baseline_normalise_x(), PIXROW::char_clip_image(), clean_noise_from_row(), resegment_box(), show_point(), tweak_row_baseline(), and DENORM::yshift_at_x().
BOX ROW::bounding_box | ( | ) | const [inline] |
Definition at line 77 of file ocrrow.h.
References bound_box.
Referenced by add_word(), OL_BUCKETS::count_children(), find_row_of_box(), make_prop_words(), make_pseudo_word(), process_selected_blobs(), process_selected_rows(), process_selected_rows_it(), process_selected_words(), process_selected_words_it(), re_segment_word(), row_space_stat(), show_point(), and word_delete().
00077 { //return bounding box 00078 return bound_box; 00079 }
void ROW::de_dump | ( | FILE * | f | ) | [inline] |
void ELIST_LINK::de_serialise_asc | ( | FILE * | f | ) | [inherited] |
Reimplemented in ICOORDELT.
Definition at line 39 of file elst.cpp.
References ABORT, ERRCODE::error(), and SERIALISE_LINKS.
00040 { 00041 SERIALISE_LINKS.error ("ELIST_LINK::de_serialise_asc", ABORT, 00042 "Don't call this, override!"); 00043 }
float ROW::descenders | ( | ) | const [inline] |
Definition at line 74 of file ocrrow.h.
References descdrop.
Referenced by make_tess_row(), and write_shm_text().
00074 { //return size 00075 return descdrop; 00076 }
void ROW::dump | ( | FILE * | f | ) | [inline] |
INT32 ROW::kern | ( | ) | const [inline] |
Definition at line 65 of file ocrrow.h.
References kerning.
Referenced by uniformly_spaced().
00065 { //return kerning 00066 return kerning; 00067 }
ROW::make_serialise | ( | ROW | ) |
void ROW::move | ( | const ICOORD | vec | ) |
Reposition row by vector.
Definition at line 117 of file ocrrow.cpp.
References baseline, bound_box, QSPLINE::move(), BOX::move(), and words.
00119 { 00120 WERD_IT it(&words); // word iterator 00121 00122 for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) 00123 it.data ()->move (vec); 00124 00125 bound_box.move (vec); 00126 baseline.move (vec); 00127 }
void ROW::plot | ( | WINDOW | window | ) |
Draw the ROW in rainbow colours.
Definition at line 167 of file ocrrow.cpp.
References WERD::plot(), and words.
00169 { 00170 WERD *word; //current word 00171 WERD_IT it = &words; //words of ROW 00172 00173 for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) { 00174 word = it.data (); 00175 word->plot (window); //in rainbow colours 00176 } 00177 }
Draw the ROW in the given colour.
Definition at line 149 of file ocrrow.cpp.
References WERD::plot(), and words.
00152 { 00153 WERD *word; //current word 00154 WERD_IT it = &words; //words of ROW 00155 00156 for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) { 00157 word = it.data (); 00158 word->plot (window, colour); //all in one colour 00159 } 00160 }
Definition at line 96 of file ocrrow.h.
References baseline, and QSPLINE::plot().
Referenced by do_re_display().
void ROW::prep_serialise | ( | ) | [inline] |
Definition at line 104 of file ocrrow.h.
References baseline, QSPLINE::prep_serialise(), and words.
00104 { //set ptrs to counts 00105 words.prep_serialise (); 00106 baseline.prep_serialise (); 00107 }
void ROW::print | ( | FILE * | fp | ) |
Display members.
Definition at line 133 of file ocrrow.cpp.
References ascrise, bound_box, descdrop, kerning, BOX::print(), spacing, tprintf(), and xheight.
Referenced by word_dumper().
00135 { 00136 tprintf ("Kerning= %d\n", kerning); 00137 tprintf ("Spacing= %d\n", spacing); 00138 bound_box.print (); 00139 tprintf ("Xheight= %f\n", xheight); 00140 tprintf ("Ascrise= %f\n", ascrise); 00141 tprintf ("Descdrop= %f\n", descdrop); 00142 }
void ROW::recalc_bounding_box | ( | ) |
Set the bounding box correctly.
Definition at line 73 of file ocrrow.cpp.
References bound_box, WERD::bounding_box(), FALSE, BOX::left(), WERD::set_flag(), TRUE, W_BOL, W_EOL, word_comparator(), and words.
Referenced by make_prop_words(), and make_rep_words().
00073 { //recalculate BB 00074 WERD *word; //current word 00075 WERD_IT it = &words; //words of ROW 00076 INT16 left; //of word 00077 INT16 prev_left; //old left 00078 00079 if (!it.empty ()) { 00080 word = it.data (); 00081 prev_left = word->bounding_box ().left (); 00082 it.forward (); 00083 while (!it.at_first ()) { 00084 word = it.data (); 00085 left = word->bounding_box ().left (); 00086 if (left < prev_left) { 00087 it.move_to_first (); 00088 //words in BB order 00089 it.sort (word_comparator); 00090 break; 00091 } 00092 prev_left = left; 00093 it.forward (); 00094 } 00095 } 00096 for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) { 00097 word = it.data (); 00098 if (it.at_first ()) 00099 word->set_flag (W_BOL, TRUE); 00100 else 00101 //not start of line 00102 word->set_flag (W_BOL, FALSE); 00103 if (it.at_last ()) 00104 word->set_flag (W_EOL, TRUE); 00105 else 00106 //not end of line 00107 word->set_flag (W_EOL, FALSE); 00108 //extend BB as reqd 00109 bound_box += word->bounding_box (); 00110 } 00111 }
void ELIST_LINK::serialise_asc | ( | FILE * | f | ) | [inherited] |
Generates an error, as it should never be called.
Definition at line 32 of file elst.cpp.
References ABORT, ERRCODE::error(), and SERIALISE_LINKS.
00033 { 00034 SERIALISE_LINKS.error ("ELIST_LINK::serialise_asc", ABORT, 00035 "Don't call this, override!"); 00036 }
INT32 ROW::space | ( | ) | const [inline] |
Definition at line 68 of file ocrrow.h.
References spacing.
Referenced by uniformly_spaced().
00068 { //return spacing 00069 return spacing; 00070 }
WERD_LIST* ROW::word_list | ( | ) | [inline] |
Definition at line 53 of file ocrrow.h.
References words.
Referenced by add_word(), apply_box_testing(), apply_box_training(), block_space_stat(), clean_noise_from_row(), clean_noise_from_words(), do_re_display(), find_row_of_box(), make_prop_words(), make_pseudo_word(), make_rep_words(), process_all_blobs(), process_all_words(), process_all_words_it(), process_selected_blobs(), process_selected_words(), process_selected_words_it(), re_segment_word(), resegment_box(), ROW_RES::ROW_RES(), row_space_stat(), show_point(), tidy_up(), and tweak_row_baseline().
00053 { //get words 00054 return &words; 00055 }
float ROW::x_height | ( | ) | const [inline] |
Definition at line 62 of file ocrrow.h.
References xheight.
Referenced by apply_box_testing(), apply_box_training(), WERD::baseline_normalise(), classify_word_pass1(), classify_word_pass2(), clean_noise_from_row(), clean_noise_from_words(), WERDIT::forward(), make_bln_copy(), make_pseudo_word(), make_reject(), recog_word(), recog_word_recursive(), resegment_box(), split_and_recog_word(), tweak_row_baseline(), uniformly_spaced(), word_bln_display(), word_display(), and write_shm_text().
00062 { //return x height 00063 return xheight; 00064 }
void tweak_row_baseline | ( | ROW * | ) | [friend] |
Remove empties.
Shift baseline to fit the blobs more accurately where they are close enough.
Definition at line 886 of file tordmain.cpp.
00888 { 00889 BOX blob_box; //bounding box 00890 C_BLOB *blob; //current blob 00891 WERD *word; //current word 00892 INT32 blob_count; //no of blobs 00893 INT32 src_index; //source segment 00894 INT32 dest_index; //destination segment 00895 INT32 *xstarts; //spline segments 00896 double *coeffs; //spline coeffs 00897 float ydiff; //baseline error 00898 float x_centre; //centre of blob 00899 //words of row 00900 WERD_IT word_it = row->word_list (); 00901 C_BLOB_IT blob_it; //blob iterator 00902 00903 blob_count = 0; 00904 for (word_it.mark_cycle_pt (); !word_it.cycled_list (); word_it.forward ()) { 00905 word = word_it.data (); //current word 00906 //get total blobs 00907 blob_count += word->cblob_list ()->length (); 00908 } 00909 if (blob_count == 0) 00910 return; 00911 xstarts = 00912 (INT32 *) alloc_mem ((blob_count + row->baseline.segments + 1) * 00913 sizeof (INT32)); 00914 coeffs = 00915 (double *) alloc_mem ((blob_count + row->baseline.segments) * 3 * 00916 sizeof (double)); 00917 00918 src_index = 0; 00919 dest_index = 0; 00920 xstarts[0] = row->baseline.xcoords[0]; 00921 for (word_it.mark_cycle_pt (); !word_it.cycled_list (); word_it.forward ()) { 00922 word = word_it.data (); //current word 00923 //blobs in word 00924 blob_it.set_to_list (word->cblob_list ()); 00925 for (blob_it.mark_cycle_pt (); !blob_it.cycled_list (); 00926 blob_it.forward ()) { 00927 blob = blob_it.data (); 00928 blob_box = blob->bounding_box (); 00929 x_centre = (blob_box.left () + blob_box.right ()) / 2.0; 00930 ydiff = blob_box.bottom () - row->base_line (x_centre); 00931 if (ydiff < 0) 00932 ydiff = -ydiff / row->x_height (); 00933 else 00934 ydiff = ydiff / row->x_height (); 00935 if (ydiff < textord_blshift_maxshift 00936 && blob_box.height () / row->x_height () > 00937 textord_blshift_xfraction) { 00938 if (xstarts[dest_index] >= x_centre) 00939 xstarts[dest_index] = blob_box.left (); 00940 coeffs[dest_index * 3] = 0; 00941 coeffs[dest_index * 3 + 1] = 0; 00942 coeffs[dest_index * 3 + 2] = blob_box.bottom (); 00943 //shift it 00944 dest_index++; 00945 xstarts[dest_index] = blob_box.right () + 1; 00946 } 00947 else { 00948 if (xstarts[dest_index] <= x_centre) { 00949 while (row->baseline.xcoords[src_index + 1] <= x_centre 00950 && src_index < row->baseline.segments - 1) { 00951 if (row->baseline.xcoords[src_index + 1] > 00952 xstarts[dest_index]) { 00953 coeffs[dest_index * 3] = 00954 row->baseline.quadratics[src_index].a; 00955 coeffs[dest_index * 3 + 1] = 00956 row->baseline.quadratics[src_index].b; 00957 coeffs[dest_index * 3 + 2] = 00958 row->baseline.quadratics[src_index].c; 00959 dest_index++; 00960 xstarts[dest_index] = 00961 row->baseline.xcoords[src_index + 1]; 00962 } 00963 src_index++; 00964 } 00965 coeffs[dest_index * 3] = 00966 row->baseline.quadratics[src_index].a; 00967 coeffs[dest_index * 3 + 1] = 00968 row->baseline.quadratics[src_index].b; 00969 coeffs[dest_index * 3 + 2] = 00970 row->baseline.quadratics[src_index].c; 00971 dest_index++; 00972 xstarts[dest_index] = row->baseline.xcoords[src_index + 1]; 00973 } 00974 } 00975 } 00976 } 00977 while (src_index < row->baseline.segments 00978 && row->baseline.xcoords[src_index + 1] <= xstarts[dest_index]) 00979 src_index++; 00980 while (src_index < row->baseline.segments) { 00981 coeffs[dest_index * 3] = row->baseline.quadratics[src_index].a; 00982 coeffs[dest_index * 3 + 1] = row->baseline.quadratics[src_index].b; 00983 coeffs[dest_index * 3 + 2] = row->baseline.quadratics[src_index].c; 00984 dest_index++; 00985 src_index++; 00986 xstarts[dest_index] = row->baseline.xcoords[src_index]; 00987 } 00988 //turn to spline 00989 row->baseline = QSPLINE (dest_index, xstarts, coeffs); 00990 free_mem(xstarts); 00991 free_mem(coeffs); 00992 }
float ROW::ascrise [private] |
QSPLINE ROW::baseline [private] |
Definition at line 133 of file ocrrow.h.
Referenced by base_line(), de_dump(), dump(), move(), plot_baseline(), prep_serialise(), ROW(), and tweak_row_baseline().
BOX ROW::bound_box [private] |
Definition at line 128 of file ocrrow.h.
Referenced by bounding_box(), move(), print(), and recalc_bounding_box().
float ROW::descdrop [private] |
INT32 ROW::kerning [private] |
INT32 ROW::spacing [private] |
WERD_LIST ROW::words [private] |
Definition at line 132 of file ocrrow.h.
Referenced by de_dump(), dump(), move(), plot(), prep_serialise(), recalc_bounding_box(), and word_list().
float ROW::xheight [private] |