Tesseract  3.02
TBLOB Struct Reference

#include <blobs.h>

List of all members.

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 172 of file blobs.h.


Constructor & Destructor Documentation

TBLOB::TBLOB ( ) [inline]

Definition at line 173 of file blobs.h.

TBLOB::TBLOB ( const TBLOB src) [inline]

Definition at line 174 of file blobs.h.

                          : outlines(NULL), next(NULL) {
    CopyFrom(src);
  }
TBLOB::~TBLOB ( ) [inline]

Definition at line 177 of file blobs.h.

           {
    Clear();
  }

Member Function Documentation

int TBLOB::BBArea ( ) const [inline]

Definition at line 216 of file blobs.h.

                     {
    int total_area = 0;
    for (TESSLINE* outline = outlines; outline != NULL; outline = outline->next)
      total_area += outline->BBArea();
    return total_area;
  }
TBOX TBLOB::bounding_box ( ) const

Definition at line 379 of file blobs.cpp.

                               {
  if (outlines == NULL)
    return TBOX(0, 0, 0, 0);
  TESSLINE *outline = outlines;
  TBOX box = outline->bounding_box();
  for (outline = outline->next; outline != NULL; outline = outline->next) {
    box += outline->bounding_box();
  }
  return box;
}
TBLOB * TBLOB::ClassifyNormalizeIfNeeded ( const DENORM **  denorm) const

Definition at line 276 of file blobs.cpp.

                                                                   {
  TBLOB* rotated_blob = NULL;
  // If necessary, copy the blob and rotate it. The rotation is always
  // +/- 90 degrees, as 180 was already taken care of.
  if ((*denorm)->block() != NULL &&
      (*denorm)->block()->classify_rotation().y() != 0.0) {
    TBOX box = bounding_box();
    int x_middle = (box.left() + box.right()) / 2;
    int y_middle = (box.top() + box.bottom()) / 2;
    rotated_blob = new TBLOB(*this);
    const FCOORD& rotation = (*denorm)->block()->classify_rotation();
    DENORM* norm = new DENORM;
    // Move the rotated blob back to the same y-position so that we
    // can still distinguish similar glyphs with differeny y-position.
    float target_y = kBlnBaselineOffset +
        (rotation.y() > 0 ? x_middle - box.left() : box.right() - x_middle);
    norm->SetupNormalization(NULL, NULL, &rotation, *denorm, NULL, 0,
                             x_middle, y_middle, 1.0f, 1.0f, 0.0f, target_y);
    //                             x_middle, y_middle, 1.0f, 1.0f, 0.0f, y_middle);
    rotated_blob->Normalize(*norm);
    *denorm = norm;
  }
  return rotated_blob;
}
void TBLOB::Clear ( )

Definition at line 317 of file blobs.cpp.

                  {
  for (TESSLINE* next_outline = NULL; outlines != NULL;
       outlines = next_outline) {
    next_outline = outlines->next;
    delete outlines;
  }
}
void TBLOB::ComputeBoundingBoxes ( )

Definition at line 359 of file blobs.cpp.

                                 {
  for (TESSLINE* outline = outlines; outline != NULL; outline = outline->next) {
    outline->ComputeBoundingBox();
  }
}
void TBLOB::CopyFrom ( const TBLOB src)

Definition at line 302 of file blobs.cpp.

                                     {
  Clear();
  TESSLINE* prev_outline = NULL;
  for (TESSLINE* srcline = src.outlines; srcline != NULL;
       srcline = srcline->next) {
    TESSLINE* new_outline = new TESSLINE(*srcline);
    if (outlines == NULL)
      outlines = new_outline;
    else
      prev_outline->next = new_outline;
    prev_outline = new_outline;
  }
}
void TBLOB::Move ( const ICOORD  vec)

Definition at line 345 of file blobs.cpp.

                                 {
  for (TESSLINE* outline = outlines; outline != NULL; outline = outline->next) {
    outline->Move(vec);
  }
}
void TBLOB::Normalize ( const DENORM denorm)

Definition at line 325 of file blobs.cpp.

                                          {
  // TODO(rays) outline->Normalize is more accurate, but breaks tests due
  // the changes it makes. Reinstate this code with a retraining.
#if 1
  for (TESSLINE* outline = outlines; outline != NULL; outline = outline->next) {
    outline->Normalize(denorm);
  }
#else
  denorm.LocalNormBlob(this);
#endif
}
int TBLOB::NumOutlines ( ) const

Definition at line 366 of file blobs.cpp.

                             {
  int result = 0;
  for (TESSLINE* outline = outlines; outline != NULL; outline = outline->next)
    ++result;
  return result;
}
TBLOB& TBLOB::operator= ( const TBLOB src) [inline]

Definition at line 180 of file blobs.h.

                                     {
    CopyFrom(src);
    return *this;
  }
void TBLOB::plot ( ScrollView window,
ScrollView::Color  color,
ScrollView::Color  child_color 
)

Definition at line 390 of file blobs.cpp.

                                              {
  for (TESSLINE* outline = outlines; outline != NULL; outline = outline->next)
    outline->plot(window, color, child_color);
}
TBLOB * TBLOB::PolygonalCopy ( C_BLOB src) [static]

Definition at line 264 of file blobs.cpp.

                                       {
  C_OUTLINE_IT ol_it = src->out_list();
  TBLOB* tblob = new TBLOB;
  ApproximateOutlineList(src->out_list(), false, &tblob->outlines);
  return tblob;
}
void TBLOB::Rotate ( const FCOORD  rotation)

Definition at line 338 of file blobs.cpp.

                                        {
  for (TESSLINE* outline = outlines; outline != NULL; outline = outline->next) {
    outline->Rotate(rotation);
  }
}
void TBLOB::Scale ( float  factor)

Definition at line 352 of file blobs.cpp.

                              {
  for (TESSLINE* outline = outlines; outline != NULL; outline = outline->next) {
    outline->Scale(factor);
  }
}

Member Data Documentation

Definition at line 224 of file blobs.h.

Definition at line 223 of file blobs.h.


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