#include <seam.h>
|
| SEAM (float priority, const TPOINT &location) |
|
| SEAM (float priority, const TPOINT &location, const SPLIT &split) |
|
float | priority () const |
|
void | set_priority (float priority) |
|
bool | HasAnySplits () const |
|
TBOX | bounding_box () const |
|
bool | CombineableWith (const SEAM &other, int max_x_dist, float max_total_priority) const |
|
void | CombineWith (const SEAM &other) |
|
bool | ContainedByBlob (const TBLOB &blob) const |
|
bool | UsesPoint (const EDGEPT *point) const |
|
bool | SharesPosition (const SEAM &other) const |
|
bool | OverlappingSplits (const SEAM &other) const |
|
void | Finalize () |
|
bool | IsHealthy (const TBLOB &blob, int min_points, int min_area) const |
|
bool | PrepareToInsertSeam (const GenericVector< SEAM * > &seams, const GenericVector< TBLOB * > &blobs, int insert_index, bool modify) |
|
bool | FindBlobWidth (const GenericVector< TBLOB * > &blobs, int index, bool modify) |
|
void | ApplySeam (bool italic_blob, TBLOB *blob, TBLOB *other_blob) const |
|
void | UndoSeam (TBLOB *blob, TBLOB *other_blob) const |
|
void | Print (const char *label) const |
|
void | Mark (ScrollView *window) const |
|
void | Hide () const |
|
void | Reveal () const |
|
float | FullPriority (int xmin, int xmax, double overlap_knob, int centered_maxwidth, double center_knob, double width_change_knob) const |
|
Definition at line 38 of file seam.h.
◆ SEAM() [1/2]
SEAM::SEAM |
( |
float |
priority, |
|
|
const TPOINT & |
location |
|
) |
| |
|
inline |
Definition at line 41 of file seam.h.
43 location_(location),
44 widthp_(0),
45 widthn_(0),
46 num_splits_(0) {}
◆ SEAM() [2/2]
SEAM::SEAM |
( |
float |
priority, |
|
|
const TPOINT & |
location, |
|
|
const SPLIT & |
split |
|
) |
| |
|
inline |
Definition at line 48 of file seam.h.
50 location_(location),
51 widthp_(0),
52 widthn_(0),
53 num_splits_(1) {
54 splits_[0] = split;
55 }
◆ ApplySeam()
void SEAM::ApplySeam |
( |
bool |
italic_blob, |
|
|
TBLOB * |
blob, |
|
|
TBLOB * |
other_blob |
|
) |
| const |
Definition at line 118 of file seam.cpp.
118 {
119 for (int s = 0; s < num_splits_; ++s) {
121 }
123
125
128
130}
void divide_blobs(TBLOB *blob, TBLOB *other_blob, bool italic_blob, const TPOINT &location)
void CorrectBlobOrder(TBLOB *next)
void EliminateDuplicateOutlines()
void ComputeBoundingBoxes()
void SplitOutlineList(TESSLINE *outlines) const
◆ bounding_box()
TBOX SEAM::bounding_box |
( |
| ) |
const |
Definition at line 31 of file seam.cpp.
31 {
32 TBOX box(location_.
x, location_.
y, location_.
x, location_.
y);
33 for (int s = 0; s < num_splits_; ++s) {
35 }
36 return box;
37}
TBOX bounding_box() const
◆ BreakPieces()
Definition at line 188 of file seam.cpp.
190 {
191 for (
int x = first; x <
last; ++x) seams[x]->
Reveal();
192
193 TESSLINE* outline = blobs[first]->outlines;
194 int next_blob = first + 1;
195
196 while (outline !=
nullptr && next_blob <=
last) {
197 if (outline->
next == blobs[next_blob]->outlines) {
198 outline->
next =
nullptr;
199 outline = blobs[next_blob]->outlines;
200 ++next_blob;
201 } else {
202 outline = outline->
next;
203 }
204 }
205}
◆ CombineableWith()
bool SEAM::CombineableWith |
( |
const SEAM & |
other, |
|
|
int |
max_x_dist, |
|
|
float |
max_total_priority |
|
) |
| const |
Definition at line 40 of file seam.cpp.
41 {
42 int dist = location_.
x - other.location_.
x;
43 if (-max_x_dist < dist && dist < max_x_dist &&
44 num_splits_ + other.num_splits_ <= kMaxNumSplits &&
45 priority_ + other.priority_ < max_total_priority &&
47 return true;
48 } else {
49 return false;
50 }
51}
bool SharesPosition(const SEAM &other) const
bool OverlappingSplits(const SEAM &other) const
◆ CombineWith()
void SEAM::CombineWith |
( |
const SEAM & |
other | ) |
|
Definition at line 54 of file seam.cpp.
54 {
55 priority_ += other.priority_;
56 location_ += other.location_;
57 location_ /= 2;
58
59 for (uint8_t s = 0; s < other.num_splits_ && num_splits_ < kMaxNumSplits; ++s)
60 splits_[num_splits_++] = other.splits_[s];
61}
◆ ContainedByBlob()
bool SEAM::ContainedByBlob |
( |
const TBLOB & |
blob | ) |
const |
|
inline |
Definition at line 73 of file seam.h.
73 {
74 for (int s = 0; s < num_splits_; ++s) {
76 }
77 return true;
78 }
bool ContainedByBlob(const TBLOB &blob) const
◆ Finalize()
Definition at line 110 of file seam.h.
110 {
111 for (int s = 0; s < num_splits_; ++s) {
114 }
115 }
◆ FindBlobWidth()
bool SEAM::FindBlobWidth |
( |
const GenericVector< TBLOB * > & |
blobs, |
|
|
int |
index, |
|
|
bool |
modify |
|
) |
| |
Definition at line 91 of file seam.cpp.
92 {
93 int num_found = 0;
94 if (modify) {
95 widthp_ = 0;
96 widthn_ = 0;
97 }
98 for (int s = 0; s < num_splits_; ++s) {
99 const SPLIT& split = splits_[s];
101
102 for (
int b = index + 1; !found_split && b < blobs.
size(); ++b) {
104 if (found_split && b - index > widthp_ && modify) widthp_ = b - index;
105 }
106
107 for (int b = index - 1; !found_split && b >= 0; --b) {
109 if (found_split && index - b > widthn_ && modify) widthn_ = index - b;
110 }
111 if (found_split) ++num_found;
112 }
113 return num_found == num_splits_;
114}
bool ContainedByBlob(const TBLOB &blob) const
◆ FullPriority()
float SEAM::FullPriority |
( |
int |
xmin, |
|
|
int |
xmax, |
|
|
double |
overlap_knob, |
|
|
int |
centered_maxwidth, |
|
|
double |
center_knob, |
|
|
double |
width_change_knob |
|
) |
| const |
Definition at line 239 of file seam.cpp.
241 {
242 if (num_splits_ == 0) return 0.0f;
243 for (int s = 1; s < num_splits_; ++s) {
245 }
246 float full_priority =
247 priority_ +
248 splits_[0].
FullPriority(xmin, xmax, overlap_knob, centered_maxwidth,
249 center_knob, width_change_knob);
250 for (int s = num_splits_ - 1; s >= 1; --s) {
252 }
253 return full_priority;
254}
float FullPriority(int xmin, int xmax, double overlap_knob, int centered_maxwidth, double center_knob, double width_change_knob) const
void SplitOutline() const
void UnsplitOutlines() const
◆ HasAnySplits()
bool SEAM::HasAnySplits |
( |
| ) |
const |
|
inline |
Definition at line 61 of file seam.h.
61{ return num_splits_ > 0; }
◆ Hide()
void SEAM::Hide |
( |
| ) |
const |
Definition at line 225 of file seam.cpp.
225 {
226 for (int s = 0; s < num_splits_; ++s) {
228 }
229}
◆ IsHealthy()
bool SEAM::IsHealthy |
( |
const TBLOB & |
blob, |
|
|
int |
min_points, |
|
|
int |
min_area |
|
) |
| const |
Definition at line 66 of file seam.cpp.
66 {
67
68
69 return num_splits_ == 0 || splits_[0].
IsHealthy(blob, min_points, min_area);
70}
bool IsHealthy(const TBLOB &blob, int min_points, int min_area) const
◆ JoinPieces()
Definition at line 210 of file seam.cpp.
211 {
212 TESSLINE* outline = blobs[first]->outlines;
213 if (!outline)
214 return;
215
216 for (
int x = first; x <
last; ++x) {
217 SEAM *seam = seams[x];
218 if (x - seam->widthn_ >= first && x + seam->widthp_ <
last) seam->
Hide();
219 while (outline->
next) outline = outline->
next;
220 outline->
next = blobs[x + 1]->outlines;
221 }
222}
◆ Mark()
Definition at line 180 of file seam.cpp.
180 {
181 for (
int s = 0; s < num_splits_; ++s) splits_[s].
Mark(window);
182}
void Mark(ScrollView *window) const
◆ OverlappingSplits()
bool SEAM::OverlappingSplits |
( |
const SEAM & |
other | ) |
const |
|
inline |
Definition at line 97 of file seam.h.
97 {
98 for (int s = 0; s < num_splits_; ++s) {
100 for (int t = 0; t < other.num_splits_; ++t) {
102 if (split1_box.
y_overlap(split2_box))
return true;
103 }
104 }
105 return false;
106 }
bool y_overlap(const TBOX &box) const
◆ PrepareToInsertSeam()
Definition at line 76 of file seam.cpp.
78 {
79 for (int s = 0; s < insert_index; ++s) {
81 }
82 if (!
FindBlobWidth(blobs, insert_index, modify))
return false;
83 for (
int s = insert_index; s < seams.
size(); ++s) {
84 if (!seams[s]->
FindBlobWidth(blobs, s + 1, modify))
return false;
85 }
86 return true;
87}
bool FindBlobWidth(const GenericVector< TBLOB * > &blobs, int index, bool modify)
◆ Print()
void SEAM::Print |
( |
const char * |
label | ) |
const |
Definition at line 154 of file seam.cpp.
154 {
156 tprintf(
" %6.2f @ (%d,%d), p=%d, n=%d ", priority_, location_.
x, location_.
y,
157 widthp_, widthn_);
158 for (int s = 0; s < num_splits_; ++s) {
160 if (s + 1 < num_splits_)
tprintf(
", ");
161 }
163}
DLLSYM void tprintf(const char *format,...)
◆ PrintSeams()
Definition at line 167 of file seam.cpp.
167 {
168 if (!seams.
empty()) {
170 for (
int x = 0; x < seams.
size(); ++x) {
172 seams[x]->Print("");
173 }
175 }
176}
◆ priority()
float SEAM::priority |
( |
| ) |
const |
|
inline |
◆ Reveal()
void SEAM::Reveal |
( |
| ) |
const |
Definition at line 232 of file seam.cpp.
232 {
233 for (int s = 0; s < num_splits_; ++s) {
235 }
236}
◆ set_priority()
void SEAM::set_priority |
( |
float |
priority | ) |
|
|
inline |
◆ SharesPosition()
bool SEAM::SharesPosition |
( |
const SEAM & |
other | ) |
const |
|
inline |
Definition at line 89 of file seam.h.
89 {
90 for (int s = 0; s < num_splits_; ++s) {
91 for (int t = 0; t < other.num_splits_; ++t)
93 }
94 return false;
95 }
◆ UndoSeam()
void SEAM::UndoSeam |
( |
TBLOB * |
blob, |
|
|
TBLOB * |
other_blob |
|
) |
| const |
Definition at line 134 of file seam.cpp.
134 {
138 }
139
141 while (outline->
next) outline = outline->
next;
144 delete other_blob;
145
146 for (int s = 0; s < num_splits_; ++s) {
148 }
151}
void UnsplitOutlineList(TBLOB *blob) const
◆ UsesPoint()
bool SEAM::UsesPoint |
( |
const EDGEPT * |
point | ) |
const |
|
inline |
Definition at line 82 of file seam.h.
82 {
83 for (int s = 0; s < num_splits_; ++s) {
84 if (splits_[s].
UsesPoint(point))
return true;
85 }
86 return false;
87 }
bool UsesPoint(const EDGEPT *point) const
The documentation for this class was generated from the following files: