tesseract  3.03
TWERD Struct Reference

#include <blobs.h>

List of all members.

Public Member Functions

 TWERD ()
 TWERD (const TWERD &src)
 ~TWERD ()
TWERDoperator= (const TWERD &src)
void BLNormalize (const BLOCK *block, const ROW *row, Pix *pix, bool inverse, float x_height, bool numeric_mode, tesseract::OcrEngineMode hint, const TBOX *norm_box, DENORM *word_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 (bool allow_detailed_fx, WERD *src)

Public Attributes

GenericVector< TBLOB * > blobs
bool latin_script

Detailed Description

Definition at line 302 of file blobs.h.


Constructor & Destructor Documentation

TWERD::TWERD ( ) [inline]

Definition at line 303 of file blobs.h.

: latin_script(false) {}
TWERD::TWERD ( const TWERD src) [inline]

Definition at line 304 of file blobs.h.

                          {
    CopyFrom(src);
  }
TWERD::~TWERD ( ) [inline]

Definition at line 307 of file blobs.h.

           {
    Clear();
  }

Member Function Documentation

void TWERD::BLNormalize ( const BLOCK block,
const ROW row,
Pix *  pix,
bool  inverse,
float  x_height,
bool  numeric_mode,
tesseract::OcrEngineMode  hint,
const TBOX norm_box,
DENORM word_denorm 
)

Definition at line 741 of file blobs.cpp.

                                             {
  TBOX word_box = bounding_box();
  if (norm_box != NULL) word_box = *norm_box;
  float word_middle = (word_box.left() + word_box.right()) / 2.0f;
  float input_y_offset = 0.0f;
  float final_y_offset = static_cast<float>(kBlnBaselineOffset);
  float scale = kBlnXHeight / x_height;
  if (hint == tesseract::OEM_CUBE_ONLY || row == NULL) {
    word_middle = word_box.left();
    input_y_offset = word_box.bottom();
    final_y_offset = 0.0f;
    if (hint == tesseract::OEM_CUBE_ONLY)
      scale = 1.0f;
  } else {
    input_y_offset = row->base_line(word_middle);
  }
  for (int b = 0; b < blobs.size(); ++b) {
    TBLOB* blob = blobs[b];
    TBOX blob_box = blob->bounding_box();
    float mid_x = (blob_box.left() + blob_box.right()) / 2.0f;
    float baseline = input_y_offset;
    float blob_scale = scale;
    if (numeric_mode) {
      baseline = blob_box.bottom();
      blob_scale = ClipToRange(kBlnXHeight * 4.0f / (3 * blob_box.height()),
                               scale, scale * 1.5f);
    } else if (row != NULL && hint != tesseract::OEM_CUBE_ONLY) {
      baseline = row->base_line(mid_x);
    }
    // The image will be 8-bit grey if the input was grey or color. Note that in
    // a grey image 0 is black and 255 is white. If the input was binary, then
    // the pix will be binary and 0 is white, with 1 being black.
    // To tell the difference pixGetDepth() will return 8 or 1.
    // The inverse flag will be true iff the word has been determined to be
    // white on black, and is independent of whether the pix is 8 bit or 1 bit.
    blob->Normalize(block, NULL, NULL, word_middle, baseline, blob_scale,
                    blob_scale, 0.0f, final_y_offset, inverse, pix);
  }
  if (word_denorm != NULL) {
    word_denorm->SetupNormalization(block, NULL, NULL, word_middle,
                                    input_y_offset, scale, scale,
                                    0.0f, final_y_offset);
    word_denorm->set_inverse(inverse);
    word_denorm->set_pix(pix);
  }
}

Definition at line 815 of file blobs.cpp.

                               {
  TBOX result;
  for (int b = 0; b < blobs.size(); ++b) {
    TBOX box = blobs[b]->bounding_box();
    result += box;
  }
  return result;
}
void TWERD::Clear ( )

Definition at line 803 of file blobs.cpp.

Definition at line 809 of file blobs.cpp.

                                 {
  for (int b = 0; b < blobs.size(); ++b) {
    blobs[b]->ComputeBoundingBoxes();
  }
}
void TWERD::CopyFrom ( const TWERD src)

Definition at line 793 of file blobs.cpp.

                                     {
  Clear();
  latin_script = src.latin_script;
  for (int b = 0; b < src.blobs.size(); ++b) {
    TBLOB* new_blob = new TBLOB(*src.blobs[b]);
    blobs.push_back(new_blob);
  }
}
void TWERD::MergeBlobs ( int  start,
int  end 
)

Definition at line 826 of file blobs.cpp.

                                         {
  if (start >= blobs.size() - 1)  return;  // Nothing to do.
  TESSLINE* outline = blobs[start]->outlines;
  for (int i = start + 1; i < end && i < blobs.size(); ++i) {
    TBLOB* next_blob = blobs[i];
    // Take the outlines from the next blob.
    if (outline == NULL) {
      blobs[start]->outlines = next_blob->outlines;
      outline = blobs[start]->outlines;
    } else {
      while (outline->next != NULL)
        outline = outline->next;
      outline->next = next_blob->outlines;
      next_blob->outlines = NULL;
    }
    // Delete the next blob and move on.
    delete next_blob;
    blobs[i] = NULL;
  }
  // Remove dead blobs from the vector.
  for (int i = start + 1; i < end && start + 1 < blobs.size(); ++i) {
    blobs.remove(start + 1);
  }
}
int TWERD::NumBlobs ( ) const [inline]

Definition at line 332 of file blobs.h.

                       {
    return blobs.size();
  }
TWERD& TWERD::operator= ( const TWERD src) [inline]

Definition at line 310 of file blobs.h.

                                     {
    CopyFrom(src);
    return *this;
  }
void TWERD::plot ( ScrollView window)

Definition at line 852 of file blobs.cpp.

                                   {
  ScrollView::Color color = WERD::NextColor(ScrollView::BLACK);
  for (int b = 0; b < blobs.size(); ++b) {
    blobs[b]->plot(window, color, ScrollView::BROWN);
    color = WERD::NextColor(color);
  }
}
TWERD * TWERD::PolygonalCopy ( bool  allow_detailed_fx,
WERD src 
) [static]

Definition at line 727 of file blobs.cpp.

                                                             {
  TWERD* tessword = new TWERD;
  tessword->latin_script = src->flag(W_SCRIPT_IS_LATIN);
  C_BLOB_IT b_it(src->cblob_list());
  for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) {
    C_BLOB* blob = b_it.data();
    TBLOB* tblob = TBLOB::PolygonalCopy(allow_detailed_fx, blob);
    tessword->blobs.push_back(tblob);
  }
  return tessword;
}

Member Data Documentation

Definition at line 343 of file blobs.h.

Definition at line 344 of file blobs.h.


The documentation for this struct was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines