tesseract  5.0.0-alpha-619-ge9db
SPLIT Struct Reference

#include <split.h>

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 34 of file split.h.

Constructor & Destructor Documentation

◆ SPLIT() [1/2]

SPLIT::SPLIT ( )
inline

Definition at line 35 of file split.h.

35 {

◆ SPLIT() [2/2]

SPLIT::SPLIT ( EDGEPT pt1,
EDGEPT pt2 
)
inline

Definition at line 36 of file split.h.

36 : point1(nullptr), point2(nullptr) {}

Member Function Documentation

◆ bounding_box()

TBOX SPLIT::bounding_box ( ) const

Definition at line 42 of file split.cpp.

43  {
44  return TBOX(
45  std::min(point1->pos.x, point2->pos.x), std::min(point1->pos.y, point2->pos.y),
46  std::max(point1->pos.x, point2->pos.x), std::max(point1->pos.y, point2->pos.y));

◆ Box12()

TBOX SPLIT::Box12 ( ) const
inline

Definition at line 41 of file split.h.

42 { return point1->SegmentBox(point2); }

◆ Box21()

TBOX SPLIT::Box21 ( ) const
inline

Definition at line 43 of file split.h.

44 { return point2->SegmentBox(point1); }

◆ ContainedByBlob()

bool SPLIT::ContainedByBlob ( const TBLOB blob) const
inline

Definition at line 62 of file split.h.

63  {
64  return blob.Contains(point1->pos) && blob.Contains(point2->pos);

◆ ContainedByOutline()

bool SPLIT::ContainedByOutline ( const TESSLINE outline) const
inline

Definition at line 66 of file split.h.

67  {
68  return outline.Contains(point1->pos) && outline.Contains(point2->pos);

◆ FullPriority()

float SPLIT::FullPriority ( int  xmin,
int  xmax,
double  overlap_knob,
int  centered_maxwidth,
double  center_knob,
double  width_change_knob 
) const

Definition at line 79 of file split.cpp.

82  {
83  TBOX box1 = Box12();
84  TBOX box2 = Box21();
85  int min_left = std::min(box1.left(), box2.left());
86  int max_right = std::max(box1.right(), box2.right());
87  if (xmin < min_left && xmax > max_right) return kBadPriority;
88 
89  float grade = 0.0f;
90  // grade_overlap.
91  int width1 = box1.width();
92  int width2 = box2.width();
93  int min_width = std::min(width1, width2);
94  int overlap = -box1.x_gap(box2);
95  if (overlap == min_width) {
96  grade += 100.0f; // Total overlap.
97  } else {
98  if (2 * overlap > min_width) overlap += 2 * overlap - min_width;
99  if (overlap > 0) grade += overlap_knob * overlap;
100  }
101  // grade_center_of_blob.
102  if (width1 <= centered_maxwidth || width2 <= centered_maxwidth) {
103  grade += std::min(static_cast<double>(kCenterGradeCap), center_knob * abs(width1 - width2));
104  }
105  // grade_width_change.
106  float width_change_grade = 20 - (max_right - min_left - std::max(width1, width2));
107  if (width_change_grade > 0.0f)
108  grade += width_change_grade * width_change_knob;
109  return grade;

◆ Hide()

void SPLIT::Hide ( ) const

Definition at line 49 of file split.cpp.

50  {
51  EDGEPT* edgept = point1;
52  do {
53  edgept->Hide();
54  edgept = edgept->next;
55  } while (!edgept->EqualPos(*point2) && edgept != point1);
56  edgept = point2;
57  do {
58  edgept->Hide();
59  edgept = edgept->next;
60  } while (!edgept->EqualPos(*point1) && edgept != point2);

◆ IsHealthy()

bool SPLIT::IsHealthy ( const TBLOB blob,
int  min_points,
int  min_area 
) const

Definition at line 113 of file split.cpp.

114  {
115  return !IsLittleChunk(min_points, min_area) &&

◆ IsLittleChunk()

bool SPLIT::IsLittleChunk ( int  min_points,
int  min_area 
) const

Definition at line 120 of file split.cpp.

121  {
122  if (point1->ShortNonCircularSegment(min_points, point2) &&
123  point1->SegmentArea(point2) < min_area) {
124  return true;
125  }
126  if (point2->ShortNonCircularSegment(min_points, point1) &&
127  point2->SegmentArea(point1) < min_area) {
128  return true;
129  }
130  return false;

◆ Mark()

void SPLIT::Mark ( ScrollView window) const

Definition at line 221 of file split.cpp.

225  {

◆ Print()

void SPLIT::Print ( ) const

Definition at line 214 of file split.cpp.

◆ Reveal()

void SPLIT::Reveal ( ) const

Definition at line 63 of file split.cpp.

64  {
65  EDGEPT* edgept = point1;
66  do {
67  edgept->Reveal();
68  edgept = edgept->next;
69  } while (!edgept->EqualPos(*point2) && edgept != point1);
70  edgept = point2;
71  do {
72  edgept->Reveal();
73  edgept = edgept->next;
74  } while (!edgept->EqualPos(*point1) && edgept != point2);

◆ SharesPosition()

bool SPLIT::SharesPosition ( const SPLIT other) const
inline

Definition at line 57 of file split.h.

58  {
59  return point1->EqualPos(*other.point1) || point1->EqualPos(*other.point2) ||
60  point2->EqualPos(*other.point1) || point2->EqualPos(*other.point2);

◆ SplitOutline()

void SPLIT::SplitOutline ( ) const

Definition at line 249 of file split.cpp.

253  {
254  EDGEPT* temp2 = point2->next;
255  EDGEPT* temp1 = point1->next;
256  /* Create two new points */
257  EDGEPT* new_point1 = make_edgept(point1->pos.x, point1->pos.y, temp1, point2);
258  EDGEPT* new_point2 = make_edgept(point2->pos.x, point2->pos.y, temp2, point1);
259  // point1 and 2 are now cross-over points, so they must have nullptr
260  // src_outlines and give their src_outline information their new
261  // replacements.
262  new_point1->src_outline = point1->src_outline;
263  new_point1->start_step = point1->start_step;
264  new_point1->step_count = point1->step_count;
265  new_point2->src_outline = point2->src_outline;
266  new_point2->start_step = point2->start_step;
267  new_point2->step_count = point2->step_count;
268  point1->src_outline = nullptr;
269  point1->start_step = 0;
270  point1->step_count = 0;

◆ SplitOutlineList()

void SPLIT::SplitOutlineList ( TESSLINE outlines) const

Definition at line 230 of file split.cpp.

234  {
235  SplitOutline();
236  while (outlines->next != nullptr) outlines = outlines->next;
237 
238  outlines->next = new TESSLINE;
239  outlines->next->loop = point1;
240  outlines->next->ComputeBoundingBox();
241 
242  outlines = outlines->next;
243 
244  outlines->next = new TESSLINE;
245  outlines->next->loop = point2;

◆ UnsplitOutlineList()

void SPLIT::UnsplitOutlineList ( TBLOB blob) const

Definition at line 274 of file split.cpp.

278  {
279  /* Modify edge points */
280  UnsplitOutlines();
281 
282  auto* outline1 = new TESSLINE;
283  outline1->next = blob->outlines;
284  blob->outlines = outline1;
285  outline1->loop = point1;
286 
287  auto* outline2 = new TESSLINE;

◆ UnsplitOutlines()

void SPLIT::UnsplitOutlines ( ) const

Definition at line 290 of file split.cpp.

294  {
295  EDGEPT* tmp1 = point1->next;
296  EDGEPT* tmp2 = point2->next;
297 
298  tmp1->next->prev = point2;
299  tmp2->next->prev = point1;
300 
301  // tmp2 is coincident with point1. point1 takes tmp2's place as tmp2 is
302  // deleted.
303  point1->next = tmp2->next;
304  point1->src_outline = tmp2->src_outline;
305  point1->start_step = tmp2->start_step;
306  point1->step_count = tmp2->step_count;
307  // Likewise point2 takes tmp1's place.
308  point2->next = tmp1->next;
309  point2->src_outline = tmp1->src_outline;
310  point2->start_step = tmp1->start_step;
311  point2->step_count = tmp1->step_count;
312 
313  delete tmp1;
314  delete tmp2;
315 
316  point1->vec.x = point1->next->pos.x - point1->pos.x;
317  point1->vec.y = point1->next->pos.y - point1->pos.y;

◆ UsesPoint()

bool SPLIT::UsesPoint ( const EDGEPT point) const
inline

Definition at line 53 of file split.h.

54  {
55  return point1 == point || point2 == point;

Member Data Documentation

◆ point1

EDGEPT* SPLIT::point1

Definition at line 100 of file split.h.

◆ point2

EDGEPT* SPLIT::point2

Definition at line 101 of file split.h.


The documentation for this struct was generated from the following files:
TBOX
Definition: cleanapi_test.cc:19
EDGEPT::SegmentArea
int SegmentArea(const EDGEPT *end) const
Definition: blobs.h:143
TESSLINE::ComputeBoundingBox
void ComputeBoundingBox()
Definition: blobs.cpp:212
TESSLINE::loop
EDGEPT * loop
Definition: blobs.h:278
SPLIT::point2
EDGEPT * point2
Definition: split.h:101
EDGEPT::EqualPos
bool EqualPos(const EDGEPT &other) const
Definition: blobs.h:126
EDGEPT::src_outline
C_OUTLINE * src_outline
Definition: blobs.h:192
SPLIT::IsLittleChunk
bool IsLittleChunk(int min_points, int min_area) const
Definition: split.cpp:120
TBLOB::outlines
TESSLINE * outlines
Definition: blobs.h:398
EDGEPT::step_count
int step_count
Definition: blobs.h:195
TESSLINE
Definition: blobs.h:201
kCenterGradeCap
const int kCenterGradeCap
Definition: split.cpp:35
TESSLINE::Contains
bool Contains(const TPOINT &pt) const
Definition: blobs.h:255
TESSLINE::next
TESSLINE * next
Definition: blobs.h:279
kBadPriority
const double kBadPriority
Definition: split.cpp:37
TBLOB::Contains
bool Contains(const TPOINT &pt) const
Definition: blobs.h:345
EDGEPT::prev
EDGEPT * prev
Definition: blobs.h:191
EDGEPT::start_step
int start_step
Definition: blobs.h:194
TPOINT::x
int16_t x
Definition: blobs.h:91
SPLIT::UnsplitOutlines
void UnsplitOutlines() const
Definition: split.cpp:290
SPLIT::Box12
TBOX Box12() const
Definition: split.h:41
TPOINT::y
int16_t y
Definition: blobs.h:92
EDGEPT::SegmentBox
TBOX SegmentBox(const EDGEPT *end) const
Definition: blobs.h:129
TBOX::width
int16_t width() const
Definition: rect.h:114
make_edgept
EDGEPT * make_edgept(int x, int y, EDGEPT *next, EDGEPT *prev)
Definition: split.cpp:136
EDGEPT::vec
VECTOR vec
Definition: blobs.h:185
EDGEPT::ShortNonCircularSegment
bool ShortNonCircularSegment(int min_points, const EDGEPT *end) const
Definition: blobs.h:156
SPLIT::Box21
TBOX Box21() const
Definition: split.h:43
TBOX::left
int16_t left() const
Definition: rect.h:71
SPLIT::SplitOutline
void SplitOutline() const
Definition: split.cpp:249
TBOX::right
int16_t right() const
Definition: rect.h:78
EDGEPT
Definition: blobs.h:97
EDGEPT::Reveal
void Reveal()
Definition: blobs.h:171
EDGEPT::Hide
void Hide()
Definition: blobs.h:168
SPLIT::point1
EDGEPT * point1
Definition: split.h:100
EDGEPT::pos
TPOINT pos
Definition: blobs.h:184
EDGEPT::next
EDGEPT * next
Definition: blobs.h:190
TBOX::x_gap
int x_gap(const TBOX &box) const
Definition: rect.h:224
TBOX
Definition: rect.h:33
TBLOB::SegmentCrossesOutline
bool SegmentCrossesOutline(const TPOINT &pt1, const TPOINT &pt2) const
Definition: blobs.h:337