DENORM Class Reference

#include <normalis.h>

List of all members.


Detailed Description

Class for undoing the baseline normalization.

See polyblob.cpp

Definition at line 53 of file normalis.h.

Public Member Functions

Private Member Functions

Private Attributes


Constructor & Destructor Documentation

DENORM::DENORM (  )  [inline]

Definition at line 56 of file normalis.h.

References base_is_row, c, m, NULL, scale_factor, segments, segs, source_row, TRUE, and x_centre.

00056              {  //constructor
00057       source_row = NULL;
00058       x_centre = 0.0f;
00059       scale_factor = 1.0f;
00060       segments = 0;
00061       segs = NULL;
00062       base_is_row = TRUE;
00063       m = c = 0;
00064     }

DENORM::DENORM ( float  x,
float  scaling,
ROW src 
) [inline]

Definition at line 65 of file normalis.h.

References base_is_row, c, m, NULL, scale_factor, segments, segs, source_row, TRUE, and x_centre.

00068                      {
00069       x_centre = x;              //just copy
00070       scale_factor = scaling;
00071       source_row = src;
00072       segments = 0;
00073       segs = NULL;
00074       base_is_row = TRUE;
00075       m = c = 0;
00076     }

DENORM::DENORM ( float  x,
float  scaling,
double  line_m,
double  line_c,
INT16  seg_count,
DENORM_SEG seg_pts,
BOOL8  using_row,
ROW src 
)

Process list of segments

It is possible, if infrequent that the segments may be out of order. since we are searching with a binary search, keep them in order.

Definition at line 106 of file normalis.cpp.

References base_is_row, c, m, NULL, scale_factor, segments, segs, source_row, x_centre, and DENORM_SEG::xstart.

00113                          {
00114   x_centre = x;                  //just copy
00115   scale_factor = scaling;
00116   source_row = src;
00117   if (seg_count > 0) {
00118     segs = new DENORM_SEG[seg_count];
00119     for (segments = 0; segments < seg_count; segments++) {
00123       if (segments == 0 || segs[segments - 1].xstart <=
00124           seg_pts[segments].xstart) {
00125         segs[segments] = seg_pts[segments];
00126       } else {
00127         int i;
00128         for (i = 0; i < segments
00129              && segs[segments - 1 - i].xstart > seg_pts[segments].xstart;
00130              ++i) {
00131           segs[segments - i ] = segs[segments - 1 - i];
00132         }
00133         segs[segments - i] = seg_pts[segments];
00134       }
00135     }//for
00136   }
00137   else {
00138     segments = 0;
00139     segs = NULL;
00140   }
00141   base_is_row = using_row;
00142   m = line_m;
00143   c = line_c;
00144 }

DENORM::DENORM ( const DENORM src  ) 

DENORM::DENORM(const DENORM &src)

Definition at line 151 of file normalis.cpp.

References NULL, segments, and segs.

00151                                 { 
00152   segments = 0;
00153   segs = NULL;
00154   *this = src;
00155 }

DENORM::~DENORM (  )  [inline]

Definition at line 88 of file normalis.h.

References segments, and segs.

00088                {
00089       if (segments > 0)
00090         delete[]segs;
00091     }


Member Function Documentation

const DENORM_SEG * DENORM::binary_search_segment ( float  src_x  )  const [private]

Binary search

Find the segment to use for the given x.

Definition at line 30 of file normalis.cpp.

References segments, and segs.

Referenced by scale_at_x(), and yshift_at_x().

00030                                                                  {
00031   int bottom, top, middle;       //binary search
00032 
00033   bottom = 0;
00034   top = segments;
00035   do {
00036     middle = (bottom + top) / 2;
00037     if (segs[middle].xstart > src_x)
00038       top = middle;
00039     else
00040       bottom = middle;
00041   }
00042   while (top - bottom > 1);
00043   return &segs[bottom];
00044 }

DENORM & DENORM::operator= ( const DENORM src  ) 

DENORM & DENORM::operator ?

Definition at line 162 of file normalis.cpp.

References base_is_row, c, m, NULL, scale_factor, segments, segs, source_row, and x_centre.

00162                                               {
00163   x_centre = src.x_centre;
00164   scale_factor = src.scale_factor;
00165   source_row = src.source_row;
00166   if (segments > 0)
00167     delete[]segs;
00168   if (src.segments > 0) {
00169     segs = new DENORM_SEG[src.segments];
00170     for (segments = 0; segments < src.segments; segments++)
00171       segs[segments] = src.segs[segments];
00172   }
00173   else {
00174     segments = 0;
00175     segs = NULL;
00176   }
00177   base_is_row = src.base_is_row;
00178   m = src.m;
00179   c = src.c;
00180   return *this;
00181 }

float DENORM::origin (  )  const [inline]

Definition at line 93 of file normalis.h.

References x_centre.

Referenced by WERD::baseline_normalise_x().

00093                          {  //get x centre
00094       return x_centre;
00095     }

ROW* DENORM::row (  )  const [inline]

Definition at line 99 of file normalis.h.

References source_row.

Referenced by make_reject(), make_tess_row(), recog_word(), recog_word_recursive(), split_and_recog_word(), and uniformly_spaced().

00099                      {  //get row
00100       return source_row;
00101     }

float DENORM::scale (  )  const [inline]

Definition at line 96 of file normalis.h.

References scale_factor.

Referenced by WERD::baseline_normalise_x(), check_block_occ(), make_tess_row(), re_estimate_x_ht(), unrej_good_chs(), word_blob_quality(), and word_char_quality().

00096                         {  //get scale
00097       return scale_factor;
00098     }

float DENORM::scale_at_x ( float  src_x  )  const

Return scaling at a given (normalized) x coord.

Definition at line 50 of file normalis.cpp.

References binary_search_segment(), scale_factor, DENORM_SEG::scale_factor, and segments.

Referenced by x(), y(), and yshift_at_x().

00050                                           {  // In normalized coords.
00051   if (segments != 0) {
00052     const DENORM_SEG* seg = binary_search_segment(src_x);
00053     if (seg->scale_factor > 0.0)
00054       return seg->scale_factor;
00055   }
00056   return scale_factor;
00057 }

float DENORM::x ( float  src_x  )  const

Denormalise an x coordinate.

Definition at line 82 of file normalis.cpp.

References scale_at_x(), and x_centre.

Referenced by make_reject(), and yshift_at_x().

00084                        {
00085   return src_x / scale_at_x(src_x) + x_centre;
00086 }

float DENORM::y ( float  src_y,
float  src_centre 
) const

Denormalise a y coordinate.

Definition at line 93 of file normalis.cpp.

References scale_at_x(), and yshift_at_x().

Referenced by make_reject().

00096                        {
00097   return (src_y - bln_baseline_offset) / scale_at_x(src_centre)
00098     + yshift_at_x(src_centre);
00099 }

float DENORM::yshift_at_x ( float  src_x  )  const

Return yshift at a given (normalized) x coord.

Definition at line 63 of file normalis.cpp.

References base_is_row, ROW::base_line(), binary_search_segment(), c, m, MAX_INT32, scale_at_x(), segments, source_row, x(), x_centre, and DENORM_SEG::ycoord.

Referenced by y().

00063                                            {  // In normalized coords.
00064   if (segments != 0) {
00065     const DENORM_SEG* seg = binary_search_segment(src_x);
00066     if (seg->ycoord == -MAX_INT32) {
00067       if (base_is_row)
00068         return source_row->base_line(x(src_x)/scale_at_x(src_x) + x_centre);
00069       else
00070         return m * x(src_x) + c;
00071     } else {
00072       return seg->ycoord;
00073     }
00074   }
00075   return source_row->base_line (x(src_x)/scale_at_x(src_x) + x_centre);
00076 }


Member Data Documentation

BOOL8 DENORM::base_is_row [private]

Using row baseline?

Definition at line 116 of file normalis.h.

Referenced by DENORM(), operator=(), and yshift_at_x().

double DENORM::c [private]

Baseline.

Definition at line 120 of file normalis.h.

Referenced by DENORM(), operator=(), and yshift_at_x().

double DENORM::m [private]

Baseline.

Definition at line 122 of file normalis.h.

Referenced by DENORM(), operator=(), and yshift_at_x().

float DENORM::scale_factor [private]

Scaling.

Definition at line 126 of file normalis.h.

Referenced by DENORM(), operator=(), scale(), and scale_at_x().

INT16 DENORM::segments [private]

No of segments.

Definition at line 118 of file normalis.h.

Referenced by binary_search_segment(), DENORM(), operator=(), scale_at_x(), yshift_at_x(), and ~DENORM().

DENORM_SEG* DENORM::segs [private]

Array of segments.

Definition at line 130 of file normalis.h.

Referenced by binary_search_segment(), DENORM(), operator=(), and ~DENORM().

ROW* DENORM::source_row [private]

Row it came from.

Definition at line 128 of file normalis.h.

Referenced by DENORM(), operator=(), row(), and yshift_at_x().

float DENORM::x_centre [private]

Middle of word.

Definition at line 124 of file normalis.h.

Referenced by DENORM(), operator=(), origin(), x(), and yshift_at_x().


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