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

#include <blobs.h>

Public Member Functions

 TBLOB ()
 
 TBLOB (const TBLOB &src)
 
 ~TBLOB ()
 
TBLOBoperator= (const TBLOB &src)
 
TBLOBClassifyNormalizeIfNeeded (const DENORM **denorm) const
 
void CopyFrom (const TBLOB &src)
 
void Clear ()
 
void Normalize (const DENORM &denorm)
 
void Rotate (const FCOORD rotation)
 
void Move (const ICOORD vec)
 
void Scale (float factor)
 
void ComputeBoundingBoxes ()
 
int NumOutlines () const
 
TBOX bounding_box () const
 
void plot (ScrollView *window, ScrollView::Color color, ScrollView::Color child_color)
 
int BBArea () const
 

Static Public Member Functions

static TBLOBPolygonalCopy (C_BLOB *src)
 

Public Attributes

TESSLINEoutlines
 
TBLOBnext
 

Detailed Description

Definition at line 174 of file blobs.h.

Constructor & Destructor Documentation

TBLOB::TBLOB ( )
inline

Definition at line 175 of file blobs.h.

175 : outlines(NULL), next(NULL) {}
#define NULL
Definition: host.h:144
TESSLINE * outlines
Definition: blobs.h:227
TBLOB * next
Definition: blobs.h:228
TBLOB::TBLOB ( const TBLOB src)
inline

Definition at line 176 of file blobs.h.

176  : outlines(NULL), next(NULL) {
177  CopyFrom(src);
178  }
#define NULL
Definition: host.h:144
TESSLINE * outlines
Definition: blobs.h:227
void CopyFrom(const TBLOB &src)
Definition: blobs.cpp:307
TBLOB * next
Definition: blobs.h:228
TBLOB::~TBLOB ( )
inline

Definition at line 179 of file blobs.h.

179  {
180  Clear();
181  }
void Clear()
Definition: blobs.cpp:322

Member Function Documentation

int TBLOB::BBArea ( ) const
inline

Definition at line 220 of file blobs.h.

220  {
221  int total_area = 0;
222  for (TESSLINE* outline = outlines; outline != NULL; outline = outline->next)
223  total_area += outline->BBArea();
224  return total_area;
225  }
#define NULL
Definition: host.h:144
TESSLINE * outlines
Definition: blobs.h:227
TBOX TBLOB::bounding_box ( ) const

Definition at line 384 of file blobs.cpp.

384  {
385  if (outlines == NULL)
386  return TBOX(0, 0, 0, 0);
387  TESSLINE *outline = outlines;
388  TBOX box = outline->bounding_box();
389  for (outline = outline->next; outline != NULL; outline = outline->next) {
390  box += outline->bounding_box();
391  }
392  return box;
393 }
TESSLINE * next
Definition: blobs.h:171
#define NULL
Definition: host.h:144
Definition: rect.h:29
TESSLINE * outlines
Definition: blobs.h:227
TBOX bounding_box() const
Definition: blobs.cpp:223
TBLOB * TBLOB::ClassifyNormalizeIfNeeded ( const DENORM **  denorm) const

Definition at line 281 of file blobs.cpp.

281  {
282  TBLOB* rotated_blob = NULL;
283  // If necessary, copy the blob and rotate it. The rotation is always
284  // +/- 90 degrees, as 180 was already taken care of.
285  if ((*denorm)->block() != NULL &&
286  (*denorm)->block()->classify_rotation().y() != 0.0) {
287  TBOX box = bounding_box();
288  int x_middle = (box.left() + box.right()) / 2;
289  int y_middle = (box.top() + box.bottom()) / 2;
290  rotated_blob = new TBLOB(*this);
291  const FCOORD& rotation = (*denorm)->block()->classify_rotation();
292  DENORM* norm = new DENORM;
293  // Move the rotated blob back to the same y-position so that we
294  // can still distinguish similar glyphs with differeny y-position.
295  float target_y = kBlnBaselineOffset +
296  (rotation.y() > 0 ? x_middle - box.left() : box.right() - x_middle);
297  norm->SetupNormalization(NULL, NULL, &rotation, *denorm, NULL, 0,
298  x_middle, y_middle, 1.0f, 1.0f, 0.0f, target_y);
299  // x_middle, y_middle, 1.0f, 1.0f, 0.0f, y_middle);
300  rotated_blob->Normalize(*norm);
301  *denorm = norm;
302  }
303  return rotated_blob;
304 }
const int kBlnBaselineOffset
Definition: normalis.h:28
#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
void Normalize(const DENORM &denorm)
Definition: blobs.cpp:330
inT16 right() const
Definition: rect.h:74
Definition: blobs.h:174
inT16 top() const
Definition: rect.h:53
TBOX bounding_box() const
Definition: blobs.cpp:384
Definition: points.h:189
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)
Definition: normalis.cpp:143
float y() const
Definition: points.h:212
TBLOB()
Definition: blobs.h:175
inT16 bottom() const
Definition: rect.h:60
void TBLOB::Clear ( )

Definition at line 322 of file blobs.cpp.

322  {
323  for (TESSLINE* next_outline = NULL; outlines != NULL;
324  outlines = next_outline) {
325  next_outline = outlines->next;
326  delete outlines;
327  }
328 }
TESSLINE * next
Definition: blobs.h:171
#define NULL
Definition: host.h:144
TESSLINE * outlines
Definition: blobs.h:227
void TBLOB::ComputeBoundingBoxes ( )

Definition at line 364 of file blobs.cpp.

364  {
365  for (TESSLINE* outline = outlines; outline != NULL; outline = outline->next) {
366  outline->ComputeBoundingBox();
367  }
368 }
#define NULL
Definition: host.h:144
TESSLINE * outlines
Definition: blobs.h:227
void TBLOB::CopyFrom ( const TBLOB src)

Definition at line 307 of file blobs.cpp.

307  {
308  Clear();
309  TESSLINE* prev_outline = NULL;
310  for (TESSLINE* srcline = src.outlines; srcline != NULL;
311  srcline = srcline->next) {
312  TESSLINE* new_outline = new TESSLINE(*srcline);
313  if (outlines == NULL)
314  outlines = new_outline;
315  else
316  prev_outline->next = new_outline;
317  prev_outline = new_outline;
318  }
319 }
TESSLINE * next
Definition: blobs.h:171
#define NULL
Definition: host.h:144
TESSLINE * outlines
Definition: blobs.h:227
void Clear()
Definition: blobs.cpp:322
void TBLOB::Move ( const ICOORD  vec)

Definition at line 350 of file blobs.cpp.

350  {
351  for (TESSLINE* outline = outlines; outline != NULL; outline = outline->next) {
352  outline->Move(vec);
353  }
354 }
#define NULL
Definition: host.h:144
TESSLINE * outlines
Definition: blobs.h:227
void TBLOB::Normalize ( const DENORM denorm)

Definition at line 330 of file blobs.cpp.

330  {
331  // TODO(rays) outline->Normalize is more accurate, but breaks tests due
332  // the changes it makes. Reinstate this code with a retraining.
333 #if 1
334  for (TESSLINE* outline = outlines; outline != NULL; outline = outline->next) {
335  outline->Normalize(denorm);
336  }
337 #else
338  denorm.LocalNormBlob(this);
339 #endif
340 }
#define NULL
Definition: host.h:144
TESSLINE * outlines
Definition: blobs.h:227
void LocalNormBlob(TBLOB *blob) const
Definition: normalis.cpp:251
int TBLOB::NumOutlines ( ) const

Definition at line 371 of file blobs.cpp.

371  {
372  int result = 0;
373  for (TESSLINE* outline = outlines; outline != NULL; outline = outline->next)
374  ++result;
375  return result;
376 }
#define NULL
Definition: host.h:144
TESSLINE * outlines
Definition: blobs.h:227
TBLOB& TBLOB::operator= ( const TBLOB src)
inline

Definition at line 182 of file blobs.h.

182  {
183  CopyFrom(src);
184  return *this;
185  }
void CopyFrom(const TBLOB &src)
Definition: blobs.cpp:307
void TBLOB::plot ( ScrollView window,
ScrollView::Color  color,
ScrollView::Color  child_color 
)

Definition at line 396 of file blobs.cpp.

397  {
398  for (TESSLINE* outline = outlines; outline != NULL; outline = outline->next)
399  outline->plot(window, color, child_color);
400 }
#define NULL
Definition: host.h:144
TESSLINE * outlines
Definition: blobs.h:227
TBLOB * TBLOB::PolygonalCopy ( C_BLOB src)
static

Definition at line 269 of file blobs.cpp.

269  {
270  C_OUTLINE_IT ol_it = src->out_list();
271  TBLOB* tblob = new TBLOB;
272  ApproximateOutlineList(src->out_list(), false, &tblob->outlines);
273  return tblob;
274 }
C_OUTLINE_LIST * out_list()
Definition: stepblob.h:42
TESSLINE * outlines
Definition: blobs.h:227
Definition: blobs.h:174
TBLOB()
Definition: blobs.h:175
void TBLOB::Rotate ( const FCOORD  rotation)

Definition at line 343 of file blobs.cpp.

343  {
344  for (TESSLINE* outline = outlines; outline != NULL; outline = outline->next) {
345  outline->Rotate(rotation);
346  }
347 }
#define NULL
Definition: host.h:144
TESSLINE * outlines
Definition: blobs.h:227
void TBLOB::Scale ( float  factor)

Definition at line 357 of file blobs.cpp.

357  {
358  for (TESSLINE* outline = outlines; outline != NULL; outline = outline->next) {
359  outline->Scale(factor);
360  }
361 }
#define NULL
Definition: host.h:144
TESSLINE * outlines
Definition: blobs.h:227

Member Data Documentation

TBLOB* TBLOB::next

Definition at line 228 of file blobs.h.

TESSLINE* TBLOB::outlines

Definition at line 227 of file blobs.h.


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