Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
olutil.h File Reference
#include "blobs.h"

Go to the source code of this file.

Macros

#define is_inside_angle(pt)   (angle_change ((pt)->prev, (pt), (pt)->next) < chop_inside_angle)
 
#define same_outline_bounds(outline, other_outline)
 
#define weighted_edgept_dist(p1, p2, chop_x_y_weight)
 

Functions

void correct_blob_order (TBLOB *blob1, TBLOB *blob2)
 
void eliminate_duplicate_outlines (TBLOB *blob)
 
void setup_blob_outlines (TBLOB *blob)
 

Macro Definition Documentation

#define is_inside_angle (   pt)    (angle_change ((pt)->prev, (pt), (pt)->next) < chop_inside_angle)

Definition at line 45 of file olutil.h.

#define same_outline_bounds (   outline,
  other_outline 
)
Value:
(outline->topleft.x == other_outline->topleft.x && \
outline->topleft.y == other_outline->topleft.y && \
outline->botright.x == other_outline->botright.x && \
outline->botright.y == other_outline->botright.y) \

Definition at line 54 of file olutil.h.

#define weighted_edgept_dist (   p1,
  p2,
  chop_x_y_weight 
)
Value:
(((p1)->pos.x - (p2)->pos.x) * \
((p1)->pos.x - (p2)->pos.x) * chop_x_y_weight + \
((p1)->pos.y - (p2)->pos.y) * \
((p1)->pos.y - (p2)->pos.y))

Definition at line 67 of file olutil.h.

Function Documentation

void correct_blob_order ( TBLOB blob1,
TBLOB blob2 
)

Definition at line 46 of file olutil.cpp.

46  {
47  TPOINT origin1;
48  TPOINT origin2;
49  TESSLINE *temp;
50 
51  blob_origin(blob1, &origin1);
52  blob_origin(blob2, &origin2);
53 
54  if (origin1.x > origin2.x) {
55  temp = blob2->outlines;
56  blob2->outlines = blob1->outlines;
57  blob1->outlines = temp;
58  }
59 }
TESSLINE * outlines
Definition: blobs.h:227
void blob_origin(TBLOB *blob, TPOINT *origin)
Definition: blobs.cpp:537
inT16 x
Definition: blobs.h:67
Definition: blobs.h:53
void eliminate_duplicate_outlines ( TBLOB blob)

Definition at line 67 of file olutil.cpp.

67  {
68  TESSLINE *outline;
69  TESSLINE *other_outline;
70  TESSLINE *last_outline;
71 
72  for (outline = blob->outlines; outline; outline = outline->next) {
73 
74  for (last_outline = outline, other_outline = outline->next;
75  other_outline;
76  last_outline = other_outline, other_outline = other_outline->next) {
77 
78  if (same_outline_bounds (outline, other_outline)) {
79  last_outline->next = other_outline->next;
80  // This doesn't leak - the outlines share the EDGEPTs.
81  other_outline->loop = NULL;
82  delete other_outline;
83  other_outline = last_outline;
84  // If it is part of a cut, then it can't be a hole any more.
85  outline->is_hole = false;
86  }
87  }
88  }
89 }
TESSLINE * next
Definition: blobs.h:171
#define NULL
Definition: host.h:144
TESSLINE * outlines
Definition: blobs.h:227
bool is_hole
Definition: blobs.h:169
#define same_outline_bounds(outline, other_outline)
Definition: olutil.h:54
EDGEPT * loop
Definition: blobs.h:170
void setup_blob_outlines ( TBLOB blob)

Definition at line 96 of file olutil.cpp.

96  {
97  TESSLINE *outline;
98 
99  for (outline = blob->outlines; outline; outline = outline->next) {
100  outline->ComputeBoundingBox();
101  }
102 }
TESSLINE * next
Definition: blobs.h:171
TESSLINE * outlines
Definition: blobs.h:227
void ComputeBoundingBox()
Definition: blobs.cpp:175