#include <con_comp.h>
Definition at line 59 of file con_comp.h.
tesseract::ConComp::ConComp |
( |
| ) |
|
tesseract::ConComp::~ConComp |
( |
| ) |
|
|
virtual |
Definition at line 40 of file con_comp.cpp.
42 ConCompPt *pt_ptr = head_;
43 while (pt_ptr !=
NULL) {
44 ConCompPt *pptNext = pt_ptr->
Next();
bool tesseract::ConComp::Add |
( |
int |
x, |
|
|
int |
y |
|
) |
| |
Definition at line 53 of file con_comp.cpp.
54 ConCompPt *pt_ptr =
new ConCompPt(x, y);
67 left_ = left_ <= x ? left_ : x;
68 top_ = top_ <= y ? top_ : y;
69 right_ = right_ >= x ? right_ : x;
70 bottom_ = bottom_ >= y ? bottom_ : y;
void SetNext(ConCompPt *pt)
int tesseract::ConComp::Bottom |
( |
| ) |
const |
|
inline |
int * tesseract::ConComp::CreateHistogram |
( |
int |
max_hist_wnd | ) |
|
Definition at line 106 of file con_comp.cpp.
107 int wid = right_ - left_ + 1,
108 hgt = bottom_ - top_ + 1,
111 if (hist_wnd > max_hist_wnd) {
112 hist_wnd = max_hist_wnd;
116 int *hist_array =
new int[wid];
117 if (hist_array ==
NULL) {
121 memset(hist_array, 0, wid *
sizeof(*hist_array));
124 ConCompPt *pt_ptr = head_;
126 while (pt_ptr !=
NULL) {
127 int x = pt_ptr->
x() - left_,
130 for (
int xdel = -hist_wnd; xdel <= hist_wnd; xdel++, xw++) {
131 if (xw >= 0 && xw < wid) {
136 pt_ptr = pt_ptr->Next();
int tesseract::ConComp::Height |
( |
| ) |
const |
|
inline |
Definition at line 70 of file con_comp.h.
70 {
return bottom_ - top_ + 1; }
int tesseract::ConComp::ID |
( |
| ) |
const |
|
inline |
int tesseract::ConComp::Left |
( |
| ) |
const |
|
inline |
static int tesseract::ConComp::Left2RightComparer |
( |
const void * |
comp1, |
|
|
const void * |
comp2 |
|
) |
| |
|
inlinestatic |
Definition at line 73 of file con_comp.h.
75 return (*(reinterpret_cast<ConComp * const *>(comp1)))->left_ +
76 (*(
reinterpret_cast<ConComp *
const *
>(comp1)))->right_ -
77 (*(reinterpret_cast<ConComp * const *>(comp2)))->left_ -
78 (*(
reinterpret_cast<ConComp *
const *
>(comp2)))->right_;
bool tesseract::ConComp::LeftMost |
( |
| ) |
const |
|
inline |
Definition at line 89 of file con_comp.h.
89 {
return left_most_; }
bool tesseract::ConComp::Merge |
( |
ConComp * |
con_comp | ) |
|
Definition at line 83 of file con_comp.cpp.
84 if (head_ ==
NULL || tail_ ==
NULL ||
85 concomp->head_ ==
NULL || concomp->tail_ ==
NULL) {
90 tail_ = concomp->tail_;
91 left_ = left_ <= concomp->left_ ? left_ : concomp->left_;
92 top_ = top_ <= concomp->top_ ? top_ : concomp->top_;
93 right_ = right_ >= concomp->right_ ? right_ : concomp->right_;
94 bottom_ = bottom_ >= concomp->bottom_ ? bottom_ : concomp->bottom_;
95 pt_cnt_ += concomp->pt_cnt_;
97 concomp->head_ =
NULL;
98 concomp->tail_ =
NULL;
void SetNext(ConCompPt *pt)
int tesseract::ConComp::PtCnt |
( |
| ) |
const |
|
inline |
int tesseract::ConComp::Right |
( |
| ) |
const |
|
inline |
static int tesseract::ConComp::Right2LeftComparer |
( |
const void * |
comp1, |
|
|
const void * |
comp2 |
|
) |
| |
|
inlinestatic |
Definition at line 82 of file con_comp.h.
84 return (*(reinterpret_cast<ConComp * const *>(comp2)))->right_ -
85 (*(
reinterpret_cast<ConComp *
const *
>(comp1)))->right_;
bool tesseract::ConComp::RightMost |
( |
| ) |
const |
|
inline |
Definition at line 90 of file con_comp.h.
90 {
return right_most_; }
ConComp ** tesseract::ConComp::Segment |
( |
int |
max_hist_wnd, |
|
|
int * |
concomp_cnt |
|
) |
| |
Definition at line 189 of file con_comp.cpp.
202 if (hist_array ==
NULL) {
212 if (seg_pt_cnt == 0) {
219 if (concomp_array ==
NULL) {
224 for (
int concomp = 0; concomp <= seg_pt_cnt; concomp++) {
225 concomp_array[concomp] =
new ConComp();
226 if (concomp_array[concomp] ==
NULL) {
228 delete []concomp_array;
233 concomp_array[concomp]->SetID(id_);
238 concomp_array[0]->left_most_ =
true;
239 concomp_array[seg_pt_cnt]->right_most_ =
true;
242 ConCompPt *pt_ptr = head_;
243 while (pt_ptr !=
NULL) {
248 for (seg_pt = 0; seg_pt < seg_pt_cnt; seg_pt++) {
249 if ((x_seg_pt[seg_pt] + left_) > pt_ptr->x()) {
255 if (concomp_array[seg_pt]->
Add(pt_ptr->x(), pt_ptr->y()) ==
false) {
257 delete []concomp_array;
261 pt_ptr = pt_ptr->Next();
266 (*concomp_cnt) = (seg_pt_cnt + 1);
268 return concomp_array;
int * SegmentHistogram(int *hist_array, int *seg_pt_cnt)
int * CreateHistogram(int max_hist_wnd)
int * tesseract::ConComp::SegmentHistogram |
( |
int * |
hist_array, |
|
|
int * |
seg_pt_cnt |
|
) |
| |
Definition at line 143 of file con_comp.cpp.
147 int wid = right_ - left_ + 1,
148 hgt = bottom_ - top_ + 1;
150 int *x_seg_pt =
new int[wid];
151 if (x_seg_pt ==
NULL) {
157 if (seg_pt_wnd > 1) {
161 for (
int x = 2; x < (wid - 2); x++) {
162 if (hist_array[x] < hist_array[x - 1] &&
163 hist_array[x] < hist_array[x - 2] &&
164 hist_array[x] <= hist_array[x + 1] &&
165 hist_array[x] <= hist_array[x + 2]) {
166 x_seg_pt[(*seg_pt_cnt)++] = x;
168 }
else if (hist_array[x] <= hist_array[x - 1] &&
169 hist_array[x] <= hist_array[x - 2] &&
170 hist_array[x] < hist_array[x + 1] &&
171 hist_array[x] < hist_array[x + 2]) {
172 x_seg_pt[(*seg_pt_cnt)++] = x;
178 if ((*seg_pt_cnt) == 0) {
void tesseract::ConComp::SetID |
( |
int |
id | ) |
|
|
inline |
void tesseract::ConComp::SetLeftMost |
( |
bool |
left_most | ) |
|
|
inline |
Definition at line 91 of file con_comp.h.
91 { left_most_ = left_most; }
void tesseract::ConComp::SetRightMost |
( |
bool |
right_most | ) |
|
|
inline |
Definition at line 92 of file con_comp.h.
92 { right_most_ = right_most;
void tesseract::ConComp::Shift |
( |
int |
dx, |
|
|
int |
dy |
|
) |
| |
Definition at line 272 of file con_comp.cpp.
273 ConCompPt *pt_ptr = head_;
275 while (pt_ptr !=
NULL) {
276 pt_ptr->
Shift(dx, dy);
277 pt_ptr = pt_ptr->Next();
void Shift(int dx, int dy)
int tesseract::ConComp::Top |
( |
| ) |
const |
|
inline |
int tesseract::ConComp::Width |
( |
| ) |
const |
|
inline |
Definition at line 69 of file con_comp.h.
69 {
return right_ - left_ + 1; }
The documentation for this class was generated from the following files: