tesseract 3.04.01

SPLIT Struct Reference

#include <split.h>

List of all members.

Public Member Functions

 SPLIT ()
 SPLIT (EDGEPT *pt1, EDGEPT *pt2)
TBOX bounding_box () const
TBOX Box12 () const
TBOX Box21 () const
void Hide () const
void Reveal () const
bool UsesPoint (const EDGEPT *point) const
bool SharesPosition (const SPLIT &other) const
bool ContainedByBlob (const TBLOB &blob) const
bool ContainedByOutline (const TESSLINE &outline) const
float FullPriority (int xmin, int xmax, double overlap_knob, int centered_maxwidth, double center_knob, double width_change_knob) const
bool IsHealthy (const TBLOB &blob, int min_points, int min_area) const
bool IsLittleChunk (int min_points, int min_area) const
void Print () const
void Mark (ScrollView *window) const
void SplitOutlineList (TESSLINE *outlines) const
void SplitOutline () const
void UnsplitOutlineList (TBLOB *blob) const
void UnsplitOutlines () const

Public Attributes

EDGEPTpoint1
EDGEPTpoint2

Detailed Description

Definition at line 37 of file split.h.


Constructor & Destructor Documentation

SPLIT::SPLIT ( ) [inline]

Definition at line 38 of file split.h.

: point1(NULL), point2(NULL) {}
SPLIT::SPLIT ( EDGEPT pt1,
EDGEPT pt2 
) [inline]

Definition at line 39 of file split.h.

: point1(pt1), point2(pt2) {}

Member Function Documentation

TBOX SPLIT::bounding_box ( ) const

Definition at line 52 of file split.cpp.

TBOX SPLIT::Box12 ( ) const [inline]

Definition at line 44 of file split.h.

{ return point1->SegmentBox(point2); }
TBOX SPLIT::Box21 ( ) const [inline]

Definition at line 46 of file split.h.

{ return point2->SegmentBox(point1); }
bool SPLIT::ContainedByBlob ( const TBLOB blob) const [inline]

Definition at line 65 of file split.h.

                                                {
    return blob.Contains(point1->pos) && blob.Contains(point2->pos);
  }
bool SPLIT::ContainedByOutline ( const TESSLINE outline) const [inline]

Definition at line 69 of file split.h.

                                                         {
    return outline.Contains(point1->pos) && outline.Contains(point2->pos);
  }
float SPLIT::FullPriority ( int  xmin,
int  xmax,
double  overlap_knob,
int  centered_maxwidth,
double  center_knob,
double  width_change_knob 
) const

Definition at line 89 of file split.cpp.

                                                          {
  TBOX box1 = Box12();
  TBOX box2 = Box21();
  int min_left = MIN(box1.left(), box2.left());
  int max_right = MAX(box1.right(), box2.right());
  if (xmin < min_left && xmax > max_right) return kBadPriority;

  float grade = 0.0f;
  // grade_overlap.
  int width1 = box1.width();
  int width2 = box2.width();
  int min_width = MIN(width1, width2);
  int overlap = -box1.x_gap(box2);
  if (overlap == min_width) {
    grade += 100.0f;  // Total overlap.
  } else {
    if (2 * overlap > min_width) overlap += 2 * overlap - min_width;
    if (overlap > 0) grade += overlap_knob * overlap;
  }
  // grade_center_of_blob.
  if (width1 <= centered_maxwidth || width2 <= centered_maxwidth) {
    grade += MIN(kCenterGradeCap, center_knob * abs(width1 - width2));
  }
  // grade_width_change.
  float width_change_grade = 20 - (max_right - min_left - MAX(width1, width2));
  if (width_change_grade > 0.0f)
    grade += width_change_grade * width_change_knob;
  return grade;
}
void SPLIT::Hide ( ) const

Definition at line 59 of file split.cpp.

                       {
  EDGEPT* edgept = point1;
  do {
    edgept->Hide();
    edgept = edgept->next;
  } while (!edgept->EqualPos(*point2) && edgept != point1);
  edgept = point2;
  do {
    edgept->Hide();
    edgept = edgept->next;
  } while (!edgept->EqualPos(*point1) && edgept != point2);
}
bool SPLIT::IsHealthy ( const TBLOB blob,
int  min_points,
int  min_area 
) const

Definition at line 123 of file split.cpp.

                                                                           {
  return !IsLittleChunk(min_points, min_area) &&
         !blob.SegmentCrossesOutline(point1->pos, point2->pos);
}
bool SPLIT::IsLittleChunk ( int  min_points,
int  min_area 
) const

Definition at line 130 of file split.cpp.

                                                            {
  if (point1->ShortNonCircularSegment(min_points, point2) &&
      point1->SegmentArea(point2) < min_area) {
    return true;
  }
  if (point2->ShortNonCircularSegment(min_points, point1) &&
      point2->SegmentArea(point1) < min_area) {
    return true;
  }
  return false;
}
void SPLIT::Mark ( ScrollView window) const

Definition at line 234 of file split.cpp.

                                         {
  window->Pen(ScrollView::GREEN);
  window->Line(point1->pos.x, point1->pos.y, point2->pos.x, point2->pos.y);
  window->UpdateWindow();
}
void SPLIT::Print ( ) const

Definition at line 227 of file split.cpp.

                        {
  tprintf("(%d,%d)--(%d,%d)", point1->pos.x, point1->pos.y, point2->pos.x,
          point2->pos.y);
}
void SPLIT::Reveal ( ) const

Definition at line 73 of file split.cpp.

                         {
  EDGEPT* edgept = point1;
  do {
    edgept->Reveal();
    edgept = edgept->next;
  } while (!edgept->EqualPos(*point2) && edgept != point1);
  edgept = point2;
  do {
    edgept->Reveal();
    edgept = edgept->next;
  } while (!edgept->EqualPos(*point1) && edgept != point2);
}
bool SPLIT::SharesPosition ( const SPLIT other) const [inline]

Definition at line 60 of file split.h.

                                                {
    return point1->EqualPos(*other.point1) || point1->EqualPos(*other.point2) ||
           point2->EqualPos(*other.point1) || point2->EqualPos(*other.point2);
  }
void SPLIT::SplitOutline ( ) const

Definition at line 262 of file split.cpp.

                               {
  EDGEPT* temp2 = point2->next;
  EDGEPT* temp1 = point1->next;
  /* Create two new points */
  EDGEPT* new_point1 = make_edgept(point1->pos.x, point1->pos.y, temp1, point2);
  EDGEPT* new_point2 = make_edgept(point2->pos.x, point2->pos.y, temp2, point1);
  // point1 and 2 are now cross-over points, so they must have NULL
  // src_outlines and give their src_outline information their new
  // replacements.
  new_point1->src_outline = point1->src_outline;
  new_point1->start_step = point1->start_step;
  new_point1->step_count = point1->step_count;
  new_point2->src_outline = point2->src_outline;
  new_point2->start_step = point2->start_step;
  new_point2->step_count = point2->step_count;
  point1->src_outline = NULL;
  point1->start_step = 0;
  point1->step_count = 0;
  point2->src_outline = NULL;
  point2->start_step = 0;
  point2->step_count = 0;
}
void SPLIT::SplitOutlineList ( TESSLINE outlines) const

Definition at line 243 of file split.cpp.

                                                     {
  SplitOutline();
  while (outlines->next != NULL) outlines = outlines->next;

  outlines->next = new TESSLINE;
  outlines->next->loop = point1;
  outlines->next->ComputeBoundingBox();

  outlines = outlines->next;

  outlines->next = new TESSLINE;
  outlines->next->loop = point2;
  outlines->next->ComputeBoundingBox();

  outlines->next->next = NULL;
}
void SPLIT::UnsplitOutlineList ( TBLOB blob) const

Definition at line 287 of file split.cpp.

                                                {
  /* Modify edge points */
  UnsplitOutlines();

  TESSLINE* outline1 = new TESSLINE;
  outline1->next = blob->outlines;
  blob->outlines = outline1;
  outline1->loop = point1;

  TESSLINE* outline2 = new TESSLINE;
  outline2->next = blob->outlines;
  blob->outlines = outline2;
  outline2->loop = point2;
}
void SPLIT::UnsplitOutlines ( ) const

Definition at line 303 of file split.cpp.

                                  {
  EDGEPT* tmp1 = point1->next;
  EDGEPT* tmp2 = point2->next;

  tmp1->next->prev = point2;
  tmp2->next->prev = point1;

  // tmp2 is coincident with point1. point1 takes tmp2's place as tmp2 is
  // deleted.
  point1->next = tmp2->next;
  point1->src_outline = tmp2->src_outline;
  point1->start_step = tmp2->start_step;
  point1->step_count = tmp2->step_count;
  // Likewise point2 takes tmp1's place.
  point2->next = tmp1->next;
  point2->src_outline = tmp1->src_outline;
  point2->start_step = tmp1->start_step;
  point2->step_count = tmp1->step_count;

  delete tmp1;
  delete tmp2;

  point1->vec.x = point1->next->pos.x - point1->pos.x;
  point1->vec.y = point1->next->pos.y - point1->pos.y;

  point2->vec.x = point2->next->pos.x - point2->pos.x;
  point2->vec.y = point2->next->pos.y - point2->pos.y;
}
bool SPLIT::UsesPoint ( const EDGEPT point) const [inline]

Definition at line 56 of file split.h.

                                            {
    return point1 == point || point2 == point;
  }

Member Data Documentation

Definition at line 103 of file split.h.

Definition at line 104 of file split.h.


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