|
tesseract 3.04.01
|
#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 | |
| EDGEPT * | point1 |
| EDGEPT * | point2 |
| TBOX SPLIT::bounding_box | ( | ) | const |
| 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] |
| bool SPLIT::ContainedByOutline | ( | const TESSLINE & | outline | ) | const [inline] |
| 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 |
| 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 |
| void SPLIT::Print | ( | ) | const |
| void SPLIT::Reveal | ( | ) | const |
| bool SPLIT::SharesPosition | ( | const SPLIT & | other | ) | const [inline] |
| 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 |
| 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] |