Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TWERD Struct Reference

#include <blobs.h>

Public Member Functions

 TWERD ()
 
 TWERD (const TWERD &src)
 
 ~TWERD ()
 
TWERDoperator= (const TWERD &src)
 
void SetupBLNormalize (const BLOCK *block, const ROW *row, float x_height, bool numeric_mode, DENORM *denorm) const
 
void Normalize (const DENORM &denorm)
 
void CopyFrom (const TWERD &src)
 
void Clear ()
 
void ComputeBoundingBoxes ()
 
int NumBlobs () const
 
TBOX bounding_box () const
 
void MergeBlobs (int start, int end)
 
void plot (ScrollView *window)
 

Static Public Member Functions

static TWERDPolygonalCopy (WERD *src)
 

Public Attributes

TBLOBblobs
 
bool latin_script
 
TWERDnext
 

Detailed Description

Definition at line 233 of file blobs.h.

Constructor & Destructor Documentation

TWERD::TWERD ( )
inline

Definition at line 234 of file blobs.h.

234 : blobs(NULL), latin_script(false), next(NULL) {}
#define NULL
Definition: host.h:144
TBLOB * blobs
Definition: blobs.h:274
bool latin_script
Definition: blobs.h:275
TWERD * next
Definition: blobs.h:276
TWERD::TWERD ( const TWERD src)
inline

Definition at line 235 of file blobs.h.

235  : blobs(NULL), next(NULL) {
236  CopyFrom(src);
237  }
#define NULL
Definition: host.h:144
TBLOB * blobs
Definition: blobs.h:274
TWERD * next
Definition: blobs.h:276
void CopyFrom(const TWERD &src)
Definition: blobs.cpp:454
TWERD::~TWERD ( )
inline

Definition at line 238 of file blobs.h.

238  {
239  Clear();
240  }
void Clear()
Definition: blobs.cpp:469

Member Function Documentation

TBOX TWERD::bounding_box ( ) const

Definition at line 483 of file blobs.cpp.

483  {
484  TBOX result;
485  for (TBLOB* blob = blobs; blob != NULL; blob = blob->next) {
486  TBOX box = blob->bounding_box();
487  result += box;
488  }
489  return result;
490 }
#define NULL
Definition: host.h:144
Definition: rect.h:29
TBLOB * blobs
Definition: blobs.h:274
Definition: blobs.h:174
void TWERD::Clear ( )

Definition at line 469 of file blobs.cpp.

469  {
470  for (TBLOB* next_blob = NULL; blobs != NULL; blobs = next_blob) {
471  next_blob = blobs->next;
472  delete blobs;
473  }
474 }
#define NULL
Definition: host.h:144
TBLOB * blobs
Definition: blobs.h:274
Definition: blobs.h:174
TBLOB * next
Definition: blobs.h:228
void TWERD::ComputeBoundingBoxes ( )

Definition at line 477 of file blobs.cpp.

477  {
478  for (TBLOB* blob = blobs; blob != NULL; blob = blob->next) {
479  blob->ComputeBoundingBoxes();
480  }
481 }
#define NULL
Definition: host.h:144
TBLOB * blobs
Definition: blobs.h:274
Definition: blobs.h:174
void TWERD::CopyFrom ( const TWERD src)

Definition at line 454 of file blobs.cpp.

454  {
455  Clear();
457  TBLOB* prev_blob = NULL;
458  for (TBLOB* srcblob = src.blobs; srcblob != NULL; srcblob = srcblob->next) {
459  TBLOB* new_blob = new TBLOB(*srcblob);
460  if (blobs == NULL)
461  blobs = new_blob;
462  else
463  prev_blob->next = new_blob;
464  prev_blob = new_blob;
465  }
466 }
#define NULL
Definition: host.h:144
TBLOB * blobs
Definition: blobs.h:274
bool latin_script
Definition: blobs.h:275
Definition: blobs.h:174
void Clear()
Definition: blobs.cpp:469
TBLOB * next
Definition: blobs.h:228
void TWERD::MergeBlobs ( int  start,
int  end 
)

Definition at line 494 of file blobs.cpp.

494  {
495  TBLOB* blob = blobs;
496  for (int i = 0; i < start && blob != NULL; ++i)
497  blob = blob->next;
498  if (blob == NULL || blob->next == NULL)
499  return;
500  TBLOB* next_blob = blob->next;
501  TESSLINE* outline = blob->outlines;
502  for (int i = start + 1; i < end && next_blob != NULL; ++i) {
503  // Take the outlines from the next blob.
504  if (outline == NULL) {
505  blob->outlines = next_blob->outlines;
506  outline = blob->outlines;
507  } else {
508  while (outline->next != NULL)
509  outline = outline->next;
510  outline->next = next_blob->outlines;
511  next_blob->outlines = NULL;
512  }
513  // Delete the next blob and move on.
514  TBLOB* dead_blob = next_blob;
515  next_blob = next_blob->next;
516  blob->next = next_blob;
517  delete dead_blob;
518  }
519 }
TESSLINE * next
Definition: blobs.h:171
#define NULL
Definition: host.h:144
TBLOB * blobs
Definition: blobs.h:274
TESSLINE * outlines
Definition: blobs.h:227
Definition: blobs.h:174
TBLOB * next
Definition: blobs.h:228
void TWERD::Normalize ( const DENORM denorm)

Definition at line 447 of file blobs.cpp.

447  {
448  for (TBLOB* blob = blobs; blob != NULL; blob = blob->next) {
449  blob->Normalize(denorm);
450  }
451 }
#define NULL
Definition: host.h:144
TBLOB * blobs
Definition: blobs.h:274
Definition: blobs.h:174
int TWERD::NumBlobs ( ) const
inline

Definition at line 263 of file blobs.h.

263  {
264  return count_blobs(blobs);
265  }
TBLOB * blobs
Definition: blobs.h:274
int count_blobs(TBLOB *blobs)
Definition: blobs.cpp:581
TWERD& TWERD::operator= ( const TWERD src)
inline

Definition at line 241 of file blobs.h.

241  {
242  CopyFrom(src);
243  return *this;
244  }
void CopyFrom(const TWERD &src)
Definition: blobs.cpp:454
void TWERD::plot ( ScrollView window)

Definition at line 522 of file blobs.cpp.

522  {
524  for (TBLOB* blob = blobs; blob != NULL; blob = blob->next) {
525  blob->plot(window, color, ScrollView::BROWN);
526  color = WERD::NextColor(color);
527  }
528 }
#define NULL
Definition: host.h:144
TBLOB * blobs
Definition: blobs.h:274
Definition: blobs.h:174
static ScrollView::Color NextColor(ScrollView::Color colour)
Definition: werd.cpp:296
TWERD * TWERD::PolygonalCopy ( WERD src)
static

Definition at line 405 of file blobs.cpp.

405  {
406  TWERD* tessword = new TWERD;
407  tessword->latin_script = src->flag(W_SCRIPT_IS_LATIN);
408  C_BLOB_IT b_it(src->cblob_list());
409  TBLOB *tail = NULL;
410  for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) {
411  C_BLOB* blob = b_it.data();
412  TBLOB* tblob = TBLOB::PolygonalCopy(blob);
413  if (tail == NULL) {
414  tessword->blobs = tblob;
415  } else {
416  tail->next = tblob;
417  }
418  tail = tblob;
419  }
420  return tessword;
421 }
C_BLOB_LIST * cblob_list()
Definition: werd.h:100
#define NULL
Definition: host.h:144
Definition: blobs.h:233
TBLOB * blobs
Definition: blobs.h:274
BOOL8 flag(WERD_FLAGS mask) const
Definition: werd.h:122
bool latin_script
Definition: blobs.h:275
TWERD()
Definition: blobs.h:234
Definition: blobs.h:174
static TBLOB * PolygonalCopy(C_BLOB *src)
Definition: blobs.cpp:269
TBLOB * next
Definition: blobs.h:228
void TWERD::SetupBLNormalize ( const BLOCK block,
const ROW row,
float  x_height,
bool  numeric_mode,
DENORM denorm 
) const

Definition at line 424 of file blobs.cpp.

426  {
427  int num_segments = 0;
428  DENORM_SEG* segs = NULL;
429  if (numeric_mode) {
430  segs = new DENORM_SEG[NumBlobs()];
431  for (TBLOB* blob = blobs; blob != NULL; blob = blob->next) {
432  TBOX blob_box = blob->bounding_box();
433  float factor = kBlnXHeight / x_height;
434  factor = ClipToRange(kBlnXHeight * 4.0f / (3 * blob_box.height()),
435  factor, factor * 1.5f);
436  segs[num_segments].xstart = blob_box.left();
437  segs[num_segments].ycoord = blob_box.bottom();
438  segs[num_segments++].scale_factor = factor;
439  }
440  }
441  denorm->SetupBLNormalize(block, row, x_height, bounding_box(),
442  num_segments, segs);
443  delete [] segs;
444 }
const int kBlnXHeight
Definition: normalis.h:27
float scale_factor
Definition: normalis.h:56
inT32 xstart
Definition: normalis.h:54
int NumBlobs() const
Definition: blobs.h:263
inT32 ycoord
Definition: normalis.h:55
#define NULL
Definition: host.h:144
inT16 left() const
Definition: rect.h:67
Definition: rect.h:29
#define f(xc, yc)
Definition: imgscale.cpp:39
TBLOB * blobs
Definition: blobs.h:274
Definition: blobs.h:174
TBOX bounding_box() const
Definition: blobs.cpp:483
inT16 height() const
Definition: rect.h:97
void SetupBLNormalize(const BLOCK *block, const ROW *row, float x_height, const TBOX &word_box, int num_segs, const DENORM_SEG *segs)
Definition: normalis.cpp:99
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
Definition: helpers.h:64
inT16 bottom() const
Definition: rect.h:60

Member Data Documentation

TBLOB* TWERD::blobs

Definition at line 274 of file blobs.h.

bool TWERD::latin_script

Definition at line 275 of file blobs.h.

TWERD* TWERD::next

Definition at line 276 of file blobs.h.


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