#include <con_comp.h>
Definition at line 59 of file con_comp.h.
◆ ConComp()
tesseract::ConComp::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();
◆ Add()
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);
64 left_ = left_ <= x ? left_ : x;
65 top_ = top_ <= y ? top_ : y;
66 right_ = right_ >= x ? right_ : x;
67 bottom_ = bottom_ >= y ? bottom_ : y;
void SetNext(ConCompPt *pt)
◆ Bottom()
int tesseract::ConComp::Bottom |
( |
| ) |
const |
|
inline |
◆ CreateHistogram()
int * tesseract::ConComp::CreateHistogram |
( |
int |
max_hist_wnd | ) |
|
Definition at line 103 of file con_comp.cpp.
104 int wid = right_ - left_ + 1,
105 hgt = bottom_ - top_ + 1,
108 if (hist_wnd > max_hist_wnd) {
109 hist_wnd = max_hist_wnd;
113 int *hist_array =
new int[wid];
115 memset(hist_array, 0, wid *
sizeof(*hist_array));
118 ConCompPt *pt_ptr = head_;
120 while (pt_ptr != NULL) {
121 int x = pt_ptr->
x() - left_,
124 for (
int xdel = -hist_wnd; xdel <= hist_wnd; xdel++, xw++) {
125 if (xw >= 0 && xw < wid) {
130 pt_ptr = pt_ptr->Next();
◆ Head()
◆ Height()
int tesseract::ConComp::Height |
( |
| ) |
const |
|
inline |
Definition at line 70 of file con_comp.h.
70 {
return bottom_ - top_ + 1; }
◆ ID()
int tesseract::ConComp::ID |
( |
| ) |
const |
|
inline |
◆ Left()
int tesseract::ConComp::Left |
( |
| ) |
const |
|
inline |
◆ Left2RightComparer()
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_;
◆ LeftMost()
bool tesseract::ConComp::LeftMost |
( |
| ) |
const |
|
inline |
Definition at line 89 of file con_comp.h.
89 {
return left_most_; }
◆ Merge()
bool tesseract::ConComp::Merge |
( |
ConComp * |
con_comp | ) |
|
Definition at line 80 of file con_comp.cpp.
81 if (head_ == NULL || tail_ == NULL ||
82 concomp->head_ == NULL || concomp->tail_ == NULL) {
87 tail_ = concomp->tail_;
88 left_ = left_ <= concomp->left_ ? left_ : concomp->left_;
89 top_ = top_ <= concomp->top_ ? top_ : concomp->top_;
90 right_ = right_ >= concomp->right_ ? right_ : concomp->right_;
91 bottom_ = bottom_ >= concomp->bottom_ ? bottom_ : concomp->bottom_;
92 pt_cnt_ += concomp->pt_cnt_;
94 concomp->head_ = NULL;
95 concomp->tail_ = NULL;
void SetNext(ConCompPt *pt)
◆ PtCnt()
int tesseract::ConComp::PtCnt |
( |
| ) |
const |
|
inline |
◆ Right()
int tesseract::ConComp::Right |
( |
| ) |
const |
|
inline |
◆ Right2LeftComparer()
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_;
◆ RightMost()
bool tesseract::ConComp::RightMost |
( |
| ) |
const |
|
inline |
Definition at line 90 of file con_comp.h.
90 {
return right_most_; }
◆ Segment()
ConComp ** tesseract::ConComp::Segment |
( |
int |
max_hist_wnd, |
|
|
int * |
concomp_cnt |
|
) |
| |
Definition at line 180 of file con_comp.cpp.
193 if (hist_array == NULL) {
203 if (seg_pt_cnt == 0) {
211 for (
int concomp = 0; concomp <= seg_pt_cnt; concomp++) {
212 concomp_array[concomp] =
new ConComp();
215 concomp_array[concomp]->SetID(id_);
220 concomp_array[0]->left_most_ =
true;
221 concomp_array[seg_pt_cnt]->right_most_ =
true;
224 ConCompPt *pt_ptr = head_;
225 while (pt_ptr != NULL) {
230 for (seg_pt = 0; seg_pt < seg_pt_cnt; seg_pt++) {
231 if ((x_seg_pt[seg_pt] + left_) > pt_ptr->x()) {
237 if (concomp_array[seg_pt]->
Add(pt_ptr->x(), pt_ptr->y()) ==
false) {
239 delete []concomp_array;
243 pt_ptr = pt_ptr->
Next();
248 (*concomp_cnt) = (seg_pt_cnt + 1);
250 return concomp_array;
int * CreateHistogram(int max_hist_wnd)
int * SegmentHistogram(int *hist_array, int *seg_pt_cnt)
◆ SegmentHistogram()
int * tesseract::ConComp::SegmentHistogram |
( |
int * |
hist_array, |
|
|
int * |
seg_pt_cnt |
|
) |
| |
Definition at line 137 of file con_comp.cpp.
141 int wid = right_ - left_ + 1,
142 hgt = bottom_ - top_ + 1;
144 int *x_seg_pt =
new int[wid];
148 if (seg_pt_wnd > 1) {
152 for (
int x = 2; x < (wid - 2); x++) {
153 if (hist_array[x] < hist_array[x - 1] &&
154 hist_array[x] < hist_array[x - 2] &&
155 hist_array[x] <= hist_array[x + 1] &&
156 hist_array[x] <= hist_array[x + 2]) {
157 x_seg_pt[(*seg_pt_cnt)++] = x;
159 }
else if (hist_array[x] <= hist_array[x - 1] &&
160 hist_array[x] <= hist_array[x - 2] &&
161 hist_array[x] < hist_array[x + 1] &&
162 hist_array[x] < hist_array[x + 2]) {
163 x_seg_pt[(*seg_pt_cnt)++] = x;
169 if ((*seg_pt_cnt) == 0) {
◆ SetID()
void tesseract::ConComp::SetID |
( |
int |
id | ) |
|
|
inline |
◆ SetLeftMost()
void tesseract::ConComp::SetLeftMost |
( |
bool |
left_most | ) |
|
|
inline |
Definition at line 91 of file con_comp.h.
91 { left_most_ = left_most; }
◆ SetRightMost()
void tesseract::ConComp::SetRightMost |
( |
bool |
right_most | ) |
|
|
inline |
Definition at line 92 of file con_comp.h.
92 { right_most_ = right_most;
◆ Shift()
void tesseract::ConComp::Shift |
( |
int |
dx, |
|
|
int |
dy |
|
) |
| |
Definition at line 254 of file con_comp.cpp.
255 ConCompPt *pt_ptr = head_;
257 while (pt_ptr != NULL) {
258 pt_ptr->
Shift(dx, dy);
259 pt_ptr = pt_ptr->Next();
void Shift(int dx, int dy)
◆ Top()
int tesseract::ConComp::Top |
( |
| ) |
const |
|
inline |
◆ Width()
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: