Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
DENORM Class Reference

`#include <normalis.h>`

List of all members.

## Public Member Functions

| DENORM ()
| DENORM (float x, float scaling, ROW *src)
| DENORM (float x, float scaling, double line_m, double line_c, inT16 seg_count, DENORM_SEG *seg_pts, BOOL8 using_row, ROW *src)
| DENORM (const DENORM &)
DENORM & | operator= (const DENORM &)
| ~DENORM ()
void | SetupBLNormalize (const BLOCK *block, const ROW *row, float x_height, const TBOX &word_box, int num_segs, const DENORM_SEG *segs)
void | SetupNormalization (const BLOCK *block, const ROW *row, const FCOORD *rotation, const DENORM *predecessor, const DENORM_SEG *segs, int num_segs, float x_origin, float y_origin, float x_scale, float y_scale, float final_xshift, float final_yshift)
void | LocalNormTransform (const TPOINT &pt, TPOINT *transformed) const
void | LocalNormTransform (const FCOORD &pt, FCOORD *transformed) const
void | NormTransform (const TPOINT &pt, TPOINT *transformed) const
void | NormTransform (const FCOORD &pt, FCOORD *transformed) const
void | LocalDenormTransform (const TPOINT &pt, TPOINT *original) const
void | LocalDenormTransform (const FCOORD &pt, FCOORD *original) const
void | DenormTransform (const TPOINT &pt, TPOINT *original) const
void | DenormTransform (const FCOORD &pt, FCOORD *original) const
void | LocalNormBlob (TBLOB *blob) const
bool | XHeightRange (int unichar_id, const UNICHARSET &unicharset, const TBOX &bbox, inT16 *min_xht, inT16 *max_xht) const
Pix * | pix () const
void | set_pix (Pix *pix)
bool | inverse () const
void | set_inverse (bool value)
const DENORM * | RootDenorm () const
const DENORM * | predecessor () const
float | x_scale () const
float | y_scale () const
const ROW * | row () const
void | set_row (ROW *row)
const BLOCK * | block () const
void | set_block (const BLOCK *block)

## Detailed Description

Definition at line 59 of file normalis.h.

## Constructor & Destructor Documentation

DENORM::DENORM | ( |  | ) |

Definition at line 33 of file normalis.cpp.

{
Init();
}

DENORM::DENORM | ( | float | x,
|  | float | scaling,
|  | ROW * | src
| ) |  |

Definition at line 38 of file normalis.cpp.

{
Init();
x_origin_ = x; // just copy
y_origin_ = 0.0f;
x_scale_ = y_scale_ = scaling;
row_ = src;
}

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

Definition at line 46 of file normalis.cpp.

{
Init();
x_origin_ = x; // just copy
y_origin_ = line_c;
ASSERT_HOST(line_m == 0.0);
x_scale_ = y_scale_ = scaling;
SetSegments(seg_pts, seg_count);
}

DENORM::DENORM | ( | const DENORM & | src | ) |

Definition at line 63 of file normalis.cpp.

{
num_segs_ = 0;
segs_ = NULL;
rotation_ = NULL;
*this = src;
}

DENORM::~DENORM | ( |  | ) |

Definition at line 92 of file normalis.cpp.

{
Clear();
}

## Member Function Documentation

const BLOCK* DENORM::block | ( |  | ) | const

inline

Definition at line 276 of file normalis.h.

{
return block_;
}

void DENORM::DenormTransform | ( | const TPOINT & | pt,
|  | TPOINT * | original
| ) |  | const

Definition at line 233 of file normalis.cpp.

{
FCOORD src_pt(pt.x, pt.y);
FCOORD float_result;
DenormTransform(src_pt, &float_result);
original->x = IntCastRounded(float_result.x());
original->y = IntCastRounded(float_result.y());
}

void DENORM::DenormTransform | ( | const FCOORD & | pt,
|  | FCOORD * | original
| ) |  | const

Definition at line 240 of file normalis.cpp.

{
LocalDenormTransform(pt, original);
if (predecessor_ != NULL) {
predecessor_->DenormTransform(*original, original);
} else if (block_ != NULL) {
original->rotate(block_->re_rotation());
}
}

bool DENORM::inverse | ( |  | ) | const

inline

Definition at line 249 of file normalis.h.

{
return inverse_;
}

void DENORM::LocalDenormTransform | ( | const TPOINT & | pt,
|  | TPOINT * | original
| ) |  | const

Definition at line 210 of file normalis.cpp.

{
FCOORD src_pt(pt.x, pt.y);
FCOORD float_result;
LocalDenormTransform(src_pt, &float_result);
original->x = IntCastRounded(float_result.x());
original->y = IntCastRounded(float_result.y());
}

void DENORM::LocalDenormTransform | ( | const FCOORD & | pt,
|  | FCOORD * | original
| ) |  | const

Definition at line 217 of file normalis.cpp.

{
FCOORD rotated(pt.x() - final_xshift_, pt.y() - final_yshift_);
if (rotation_ != NULL) {
FCOORD inverse_rotation(rotation_->x(), -rotation_->y());
rotated.rotate(inverse_rotation);
}
original->set_x(rotated.x() / x_scale_ + x_origin_);
float y_scale = y_scale_;
if (num_segs_ > 0)
y_scale = YScaleAtOrigX(original->x());
original->set_y(rotated.y() / y_scale + YOriginAtOrigX(original->x()));
}

void DENORM::LocalNormBlob | ( | TBLOB * | blob | ) | const

Definition at line 251 of file normalis.cpp.

{
TBOX blob_box = blob->bounding_box();
float x_center = (blob_box.left() + blob_box.right()) / 2.0f;
ICOORD translation(-IntCastRounded(x_origin_),
-IntCastRounded(YOriginAtOrigX(x_center)));
blob->Move(translation);
// Note that the old way of scaling only allowed for a single
// scale factor.
float scale = YScaleAtOrigX(x_center);
if (scale != 1.0f)
blob->Scale(scale);
if (rotation_ != NULL)
blob->Rotate(*rotation_);
translation.set_x(IntCastRounded(final_xshift_));
translation.set_y(IntCastRounded(final_yshift_));
blob->Move(translation);
}

void DENORM::LocalNormTransform | ( | const TPOINT & | pt,
|  | TPOINT * | transformed
| ) |  | const

Definition at line 170 of file normalis.cpp.

{
FCOORD src_pt(pt.x, pt.y);
FCOORD float_result;
LocalNormTransform(src_pt, &float_result);
transformed->x = IntCastRounded(float_result.x());
transformed->y = IntCastRounded(float_result.y());
}

void DENORM::LocalNormTransform | ( | const FCOORD & | pt,
|  | FCOORD * | transformed
| ) |  | const

Definition at line 177 of file normalis.cpp.

{
FCOORD translated(pt.x() - x_origin_, pt.y() - YOriginAtOrigX(pt.x()));
translated.set_x(translated.x() * x_scale_);
translated.set_y(translated.y() * YScaleAtOrigX(pt.x()));
if (rotation_ != NULL)
translated.rotate(*rotation_);
transformed->set_x(translated.x() + final_xshift_);
transformed->set_y(translated.y() + final_yshift_);
}

void DENORM::NormTransform | ( | const TPOINT & | pt,
|  | TPOINT * | transformed
| ) |  | const

Definition at line 190 of file normalis.cpp.

{
FCOORD src_pt(pt.x, pt.y);
FCOORD float_result;
NormTransform(src_pt, &float_result);
transformed->x = IntCastRounded(float_result.x());
transformed->y = IntCastRounded(float_result.y());
}

void DENORM::NormTransform | ( | const FCOORD & | pt,
|  | FCOORD * | transformed
| ) |  | const

Definition at line 197 of file normalis.cpp.

{
FCOORD src_pt(pt);
if (predecessor_ != NULL) {
predecessor_->NormTransform(pt, &src_pt);
} else if (block_ != NULL) {
FCOORD fwd_rotation(block_->re_rotation().x(), -block_->re_rotation().y());
src_pt.rotate(fwd_rotation);
}
LocalNormTransform(src_pt, transformed);
}

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

Definition at line 71 of file normalis.cpp.

{
Clear();
inverse_ = src.inverse_;
pix_ = src.pix_;
block_ = src.block_;
row_ = src.row_;
if (src.rotation_ == NULL)
rotation_ = NULL;
else
rotation_ = new FCOORD(*src.rotation_);
predecessor_ = src.predecessor_;
SetSegments(src.segs_, src.num_segs_);
x_origin_ = src.x_origin_;
y_origin_ = src.y_origin_;
x_scale_ = src.x_scale_;
y_scale_ = src.y_scale_;
final_xshift_ = src.final_xshift_;
final_yshift_ = src.final_yshift_;
return *this;
}

Pix* DENORM::pix | ( |  | ) | const

inline

Definition at line 243 of file normalis.h.

{
return pix_;
}

const DENORM* DENORM::predecessor | ( |  | ) | const

inline

Definition at line 260 of file normalis.h.

{
return predecessor_;
}

const DENORM* DENORM::RootDenorm | ( |  | ) | const

inline

Definition at line 255 of file normalis.h.

{
if (predecessor_ != NULL)
return predecessor_->RootDenorm();
return this;
}

const ROW* DENORM::row | ( |  | ) | const

inline

Definition at line 270 of file normalis.h.

{
return row_;
}

void DENORM::set_block | ( | const BLOCK * | block | ) |

inline

Definition at line 279 of file normalis.h.

{
block_ = block;
}

void DENORM::set_inverse | ( | bool | value | ) |

inline

Definition at line 252 of file normalis.h.

{
inverse_ = value;
}

void DENORM::set_pix | ( | Pix * | pix | ) |

inline

Definition at line 246 of file normalis.h.

{
pix_ = pix;
}

void DENORM::set_row | ( | ROW * | row | ) |

inline

Definition at line 273 of file normalis.h.

{
row_ = row;
}

void DENORM::SetupBLNormalize | ( | const BLOCK * | block,
|  | const ROW * | row,
|  | float | x_height,
|  | const TBOX & | word_box,
|  | int | num_segs,
|  | const DENORM_SEG * | segs
| ) |  |

Definition at line 99 of file normalis.cpp.

{
float scale = kBlnXHeight / x_height;
float x_origin = (word_box.left() + word_box.right()) / 2.0f;
float y_origin = 0.0f;
if (num_segs == 0 && row == NULL) {
y_origin = word_box.bottom();
}
SetupNormalization(block, row, NULL, NULL, segs, num_segs,
x_origin, y_origin, scale, scale,
0.0f, static_cast<float>(kBlnBaselineOffset));
}

void DENORM::SetupNormalization | ( | const BLOCK * | block,
|  | const ROW * | row,
|  | const FCOORD * | rotation,
|  | const DENORM * | predecessor,
|  | const DENORM_SEG * | segs,
|  | int | num_segs,
|  | float | x_origin,
|  | float | y_origin,
|  | float | x_scale,
|  | float | y_scale,
|  | float | final_xshift,
|  | float | final_yshift
| ) |  |

Definition at line 143 of file normalis.cpp.

{
Clear();
block_ = block;
row_ = row;
if (rotation == NULL)
rotation_ = NULL;
else
rotation_ = new FCOORD(*rotation);
predecessor_ = predecessor;
SetSegments(segs, num_segs);
x_origin_ = x_origin;
y_origin_ = y_origin;
x_scale_ = x_scale;
y_scale_ = y_scale;
final_xshift_ = final_xshift;
final_yshift_ = final_yshift;
}

float DENORM::x_scale | ( |  | ) | const

inline

Definition at line 264 of file normalis.h.

{
return x_scale_;
}

bool DENORM::XHeightRange | ( | int | unichar_id,
|  | const UNICHARSET & | unicharset,
|  | const TBOX & | bbox,
|  | inT16 * | min_xht,
|  | inT16 * | max_xht
| ) |  | const

Definition at line 275 of file normalis.cpp.

{
// Clip the top and bottom to the limit of normalized feature space.
int top = ClipToRange<int>(bbox.top(), 0, kBlnCellHeight - 1);
int bottom = ClipToRange<int>(bbox.bottom(), 0, kBlnCellHeight - 1);
// A tolerance of yscale corresponds to 1 pixel in the image.
double tolerance = y_scale();
int min_bottom, max_bottom, min_top, max_top;
unicharset.get_top_bottom(unichar_id, &min_bottom, &max_bottom,
&min_top, &max_top);
// Default returns indicate a mis-fit.
*min_xht = 0;
*max_xht = 0;
// Chars with a misfitting bottom might be sub/superscript/dropcap, or might
// just be wrongly classified. Return an empty range so they have to be
// good to be considered.
if (bottom < min_bottom - tolerance || bottom > max_bottom + tolerance) {
return false;
}
// To help very high cap/xheight ratio fonts accept the correct x-height,
// and to allow the large caps in small caps to accept the xheight of the
// small caps, add kBlnBaselineOffset to chars with a maximum max.
if (max_top == kBlnCellHeight - 1)
max_top += kBlnBaselineOffset;
int height = top - kBlnBaselineOffset;
double min_height = min_top - kBlnBaselineOffset - tolerance;
double max_height = max_top - kBlnBaselineOffset + tolerance;
if (min_height <= 0.0) {
if (height <= 0 || max_height > 0)
*max_xht = MAX_INT16; // Anything will do.
} else if (height > 0) {
int result = IntCastRounded(height * kBlnXHeight / y_scale() / min_height);
*max_xht = static_cast< inT16 >(ClipToRange(result, 0, MAX_INT16));
}
if (max_height > 0.0 && height > 0) {
int result = IntCastRounded(height * kBlnXHeight / y_scale() / max_height);
*min_xht = static_cast< inT16 >(ClipToRange(result, 0, MAX_INT16));
}
return true;
}

float DENORM::y_scale | ( |  | ) | const

inline

Definition at line 267 of file normalis.h.

{
return y_scale_;
}

The documentation for this class was generated from the following files:

- /mnt/data/src/tesseract-ocr/ccstruct/normalis.h
- /mnt/data/src/tesseract-ocr/ccstruct/normalis.cpp