#include <normalis.h>
|
| DENORM () |
|
| DENORM (const DENORM &) |
|
DENORM & | operator= (const DENORM &) |
|
| ~DENORM () |
|
void | SetupNormalization (const BLOCK *block, const FCOORD *rotation, const DENORM *predecessor, float x_origin, float y_origin, float x_scale, float y_scale, float final_xshift, float final_yshift) |
|
void | SetupNonLinear (const DENORM *predecessor, const TBOX &box, float target_width, float target_height, float final_xshift, float final_yshift, const GenericVector< GenericVector< int > > &x_coords, const GenericVector< GenericVector< int > > &y_coords) |
|
void | LocalNormTransform (const TPOINT &pt, TPOINT *transformed) const |
|
void | LocalNormTransform (const FCOORD &pt, FCOORD *transformed) const |
|
void | NormTransform (const DENORM *first_norm, const TPOINT &pt, TPOINT *transformed) const |
|
void | NormTransform (const DENORM *first_norm, 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 DENORM *last_denorm, const TPOINT &pt, TPOINT *original) const |
|
void | DenormTransform (const DENORM *last_denorm, const FCOORD &pt, FCOORD *original) const |
|
void | LocalNormBlob (TBLOB *blob) const |
|
void | XHeightRange (int unichar_id, const UNICHARSET &unicharset, const TBOX &bbox, float *min_xht, float *max_xht, float *yshift) const |
|
void | Print () 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 BLOCK * | block () const |
|
void | set_block (const BLOCK *block) |
|
Definition at line 49 of file normalis.h.
◆ DENORM() [1/2]
◆ DENORM() [2/2]
DENORM::DENORM |
( |
const DENORM & |
src | ) |
|
◆ ~DENORM()
◆ block()
const BLOCK* DENORM::block |
( |
| ) |
const |
|
inline |
◆ DenormTransform() [1/2]
void DENORM::DenormTransform |
( |
const DENORM * |
last_denorm, |
|
|
const FCOORD & |
pt, |
|
|
FCOORD * |
original |
|
) |
| const |
Definition at line 397 of file normalis.cpp.
401 if (last_denorm !=
this) {
402 if (predecessor_ !=
nullptr) {
404 }
else if (block_ !=
nullptr) {
◆ DenormTransform() [2/2]
void DENORM::DenormTransform |
( |
const DENORM * |
last_denorm, |
|
|
const TPOINT & |
pt, |
|
|
TPOINT * |
original |
|
) |
| const |
◆ inverse()
bool DENORM::inverse |
( |
| ) |
const |
|
inline |
◆ LocalDenormTransform() [1/2]
void DENORM::LocalDenormTransform |
( |
const FCOORD & |
pt, |
|
|
FCOORD * |
original |
|
) |
| const |
Definition at line 366 of file normalis.cpp.
368 FCOORD rotated(pt.
x() - final_xshift_, pt.
y() - final_yshift_);
369 if (x_map_ !=
nullptr && y_map_ !=
nullptr) {
371 original->
set_x(x + x_origin_);
373 original->
set_y(y + y_origin_);
375 if (rotation_ !=
nullptr) {
376 FCOORD inverse_rotation(rotation_->
x(), -rotation_->
y());
377 rotated.
rotate(inverse_rotation);
379 original->
set_x(rotated.x() / x_scale_ + x_origin_);
◆ LocalDenormTransform() [2/2]
void DENORM::LocalDenormTransform |
( |
const TPOINT & |
pt, |
|
|
TPOINT * |
original |
|
) |
| const |
◆ LocalNormBlob()
void DENORM::LocalNormBlob |
( |
TBLOB * |
blob | ) |
const |
Definition at line 411 of file normalis.cpp.
414 blob->
Move(translation);
415 if (y_scale_ != 1.0f)
416 blob->
Scale(y_scale_);
417 if (rotation_ !=
nullptr)
421 blob->
Move(translation);
◆ LocalNormTransform() [1/2]
void DENORM::LocalNormTransform |
( |
const FCOORD & |
pt, |
|
|
FCOORD * |
transformed |
|
) |
| const |
Definition at line 312 of file normalis.cpp.
314 FCOORD translated(pt.
x() - x_origin_, pt.
y() - y_origin_);
315 if (x_map_ !=
nullptr && y_map_ !=
nullptr) {
317 translated.set_x((*x_map_)[x]);
319 translated.set_y((*y_map_)[y]);
321 translated.set_x(translated.x() * x_scale_);
322 translated.set_y(translated.y() * y_scale_);
323 if (rotation_ !=
nullptr)
324 translated.rotate(*rotation_);
326 transformed->
set_x(translated.x() + final_xshift_);
327 transformed->
set_y(translated.y() + final_yshift_);
◆ LocalNormTransform() [2/2]
void DENORM::LocalNormTransform |
( |
const TPOINT & |
pt, |
|
|
TPOINT * |
transformed |
|
) |
| const |
◆ NormTransform() [1/2]
void DENORM::NormTransform |
( |
const DENORM * |
first_norm, |
|
|
const FCOORD & |
pt, |
|
|
FCOORD * |
transformed |
|
) |
| const |
Definition at line 342 of file normalis.cpp.
346 if (first_norm !=
this) {
347 if (predecessor_ !=
nullptr) {
349 }
else if (block_ !=
nullptr) {
352 src_pt.
rotate(fwd_rotation);
◆ NormTransform() [2/2]
void DENORM::NormTransform |
( |
const DENORM * |
first_norm, |
|
|
const TPOINT & |
pt, |
|
|
TPOINT * |
transformed |
|
) |
| const |
◆ operator=()
Definition at line 47 of file normalis.cpp.
50 inverse_ = src.inverse_;
51 predecessor_ = src.predecessor_;
54 if (src.rotation_ ==
nullptr)
57 rotation_ =
new FCOORD(*src.rotation_);
58 x_origin_ = src.x_origin_;
59 y_origin_ = src.y_origin_;
60 x_scale_ = src.x_scale_;
61 y_scale_ = src.y_scale_;
62 final_xshift_ = src.final_xshift_;
63 final_yshift_ = src.final_yshift_;
◆ pix()
Pix* DENORM::pix |
( |
| ) |
const |
|
inline |
◆ predecessor()
const DENORM* DENORM::predecessor |
( |
| ) |
const |
|
inline |
◆ Print()
void DENORM::Print |
( |
| ) |
const |
Definition at line 504 of file normalis.cpp.
506 if (pix_ !=
nullptr) {
507 tprintf(
"Pix dimensions %d x %d x %d\n",
508 pixGetWidth(pix_), pixGetHeight(pix_), pixGetDepth(pix_));
513 tprintf(
"Block rotation %g, %g\n",
516 tprintf(
"Input Origin = (%g, %g)\n", x_origin_, y_origin_);
517 if (x_map_ !=
nullptr && y_map_ !=
nullptr) {
519 for (
int x = 0; x < x_map_->
size(); ++x) {
523 for (
int y = 0; y < y_map_->
size(); ++y) {
528 tprintf(
"Scale = (%g, %g)\n", x_scale_, y_scale_);
529 if (rotation_ !=
nullptr)
530 tprintf(
"Rotation = (%g, %g)\n", rotation_->
x(), rotation_->
y());
532 tprintf(
"Final Origin = (%g, %g)\n", final_xshift_, final_xshift_);
533 if (predecessor_ !=
nullptr) {
535 predecessor_->
Print();
◆ RootDenorm()
const DENORM* DENORM::RootDenorm |
( |
| ) |
const |
|
inline |
Definition at line 257 of file normalis.h.
259 if (predecessor_ !=
nullptr)
◆ set_block()
void DENORM::set_block |
( |
const BLOCK * |
block | ) |
|
|
inline |
◆ set_inverse()
void DENORM::set_inverse |
( |
bool |
value | ) |
|
|
inline |
◆ set_pix()
void DENORM::set_pix |
( |
Pix * |
pix | ) |
|
|
inline |
◆ SetupNonLinear()
Definition at line 267 of file normalis.cpp.
281 int width = box.
width();
282 int height = box.
height();
284 ComputeRunlengthImage(box, x_coords, y_coords, &minruns);
287 ComputeEdgeDensityProfiles(box, minruns, x_map_, y_map_);
290 (*x_map_)[width] = target_width;
291 for (
int x = width - 1; x >= 0; --x) {
292 (*x_map_)[x] = (*x_map_)[x + 1] - (*x_map_)[x] * target_width;
294 (*y_map_)[height] = target_height;
295 for (
int y = height - 1; y >= 0; --y) {
296 (*y_map_)[y] = (*y_map_)[y + 1] - (*y_map_)[y] * target_height;
298 x_origin_ = box.
left();
300 final_xshift_ = final_xshift;
301 final_yshift_ = final_yshift;
◆ SetupNormalization()
void DENORM::SetupNormalization |
( |
const BLOCK * |
block, |
|
|
const FCOORD * |
rotation, |
|
|
const DENORM * |
predecessor, |
|
|
float |
x_origin, |
|
|
float |
y_origin, |
|
|
float |
x_scale, |
|
|
float |
y_scale, |
|
|
float |
final_xshift, |
|
|
float |
final_yshift |
|
) |
| |
Definition at line 95 of file normalis.cpp.
104 if (rotation ==
nullptr)
107 rotation_ =
new FCOORD(*rotation);
109 x_origin_ = x_origin;
110 y_origin_ = y_origin;
113 final_xshift_ = final_xshift;
114 final_yshift_ = final_yshift;
◆ x_scale()
float DENORM::x_scale |
( |
| ) |
const |
|
inline |
◆ XHeightRange()
void DENORM::XHeightRange |
( |
int |
unichar_id, |
|
|
const UNICHARSET & |
unicharset, |
|
|
const TBOX & |
bbox, |
|
|
float * |
min_xht, |
|
|
float * |
max_xht, |
|
|
float * |
yshift |
|
) |
| const |
Definition at line 427 of file normalis.cpp.
449 int min_bottom, max_bottom, min_top, max_top;
454 double midx = (bbox.
left() + bbox.
right()) / 2.0;
455 double ydiff = (bbox.
top() - bbox.
bottom()) + 2.0;
457 FCOORD mid_high(midx, bbox.
bottom() + ydiff), tmid_high;
462 double yscale = tmid_high.pt_to_pt_dist(tmid_bot) / ydiff;
465 int bln_yshift = 0, bottom_shift = 0, top_shift = 0;
466 if (bottom < min_bottom - tolerance) {
467 bottom_shift = bottom - min_bottom;
468 }
else if (bottom > max_bottom + tolerance) {
469 bottom_shift = bottom - max_bottom;
471 if (top < min_top - tolerance) {
472 top_shift = top - min_top;
473 }
else if (top > max_top + tolerance) {
474 top_shift = top - max_top;
476 if ((top_shift >= 0 && bottom_shift > 0) ||
477 (top_shift < 0 && bottom_shift < 0)) {
478 bln_yshift = (top_shift + bottom_shift) / 2;
480 *yshift = bln_yshift * yscale;
497 float result = height *
kBlnXHeight * yscale / min_height;
499 result = height *
kBlnXHeight * yscale / max_height;
◆ y_scale()
float DENORM::y_scale |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following files: