43 while (pt_ptr != NULL) {
64 left_ = left_ <= x ? left_ : x;
65 top_ = top_ <= y ? top_ : y;
66 right_ = right_ >= x ? right_ : x;
67 bottom_ = bottom_ >= y ? bottom_ : y;
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;
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));
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();
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) {
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;
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;
257 while (pt_ptr != NULL) {
258 pt_ptr->
Shift(dx, dy);
259 pt_ptr = pt_ptr->
Next();
int * CreateHistogram(int max_hist_wnd)
ConComp ** Segment(int max_hist_wnd, int *concomp_cnt)
void Shift(int dx, int dy)
int * SegmentHistogram(int *hist_array, int *seg_pt_cnt)
void SetNext(ConCompPt *pt)
void Shift(int dx, int dy)
bool Merge(ConComp *con_comp)