34 static void minmax_xy(
int, plstruct *,
int *,
int *,
int *,
int *);
71 void apclust(ap_t *ap,
int np, plstruct *plstr) {
77 int k,j,ix1,ix2,iy1,iy2,nwork,nx,ny,kk;
78 float i2compare,icompare;
83 i2compare = ap->thresh;
84 icompare = i2compare * ap->multiply;
89 minmax_xy(np,plstr,&ix1,&ix2,&iy1,&iy2);
93 work = cpl_malloc(nwork*
sizeof(*work));
94 for (i = 0; i < nwork; i++)
96 for (k = 0; k < np; k++) {
99 kk = (j - iy1)*nx + i - ix1;
105 for (j = iy1; j <= iy2; j++) {
106 for (i = ix1; i <= ix2; i++) {
107 kk = (j - iy1)*nx + i - ix1;
110 ap->lastline[i + 1] = 0;
112 if (plstr[k].zsm > icompare) {
116 is = ap->lastline[i];
117 ip = ap->lastline[i + 1];
126 if (ap->ipstack > ap->maxpa*3/4) {
127 for (ik = 0; ik < ap->maxpa*3/8; ik++)
130 ip = ap->pstack[ap->ipstack++];
131 ap->parent[ip].first = ap->bstack[ap->ibstack];
132 ap->parent[ip].pnop = 0;
133 ap->parent[ip].pnbp = 0;
134 ap->parent[ip].growing = 0;
139 ap->parent[ip].touch = 1;
141 ap->parent[ip].touch = 0;
153 }
else if ((ip > 0 && is > 0) && (ip != is)) {
157 ap->blink[ap->parent[ip].last] = ap->parent[is].first;
161 ap->parent[ip].last = ap->parent[is].last;
162 ap->parent[ip].pnop += ap->parent[is].pnop;
163 ap->parent[ip].pnbp += ap->parent[is].pnbp;
167 ib = ap->parent[is].first;
170 i1 = ap->plessey[ib].x;
171 if (ap->lastline[i1 + 1] == is)
172 ap->lastline[i1 + 1] = ip;
173 if (ap->parent[is].last == ib)
181 ap->parent[is].pnop = -1;
182 ap->parent[is].pnbp = -1;
186 ap->pstack[--ap->ipstack] = is;
191 ib = ap->bstack[ap->ibstack++];
195 if (ap->parent[ip].pnop > 0)
196 ap->blink[ap->parent[ip].last] = ib;
200 ap->parent[ip].last = ib;
204 ap->plessey[ib].x = i;
205 ap->plessey[ib].y = j;
206 ap->plessey[ib].z = plstr[k].z;
207 ap->plessey[ib].zsm = plstr[k].zsm;
211 ap->parent[ip].pnop++;
215 ap->lastline[i + 1] = ip;
221 ap->lastline[i + 1] = 0;
230 if(ap->lastline[1] > 0 )
231 ap->parent[ap->lastline[1]].touch |= 2;
232 if(ap->lastline[ap->lsiz] > 0)
233 ap->parent[ap->lastline[ap->lsiz]].touch |= 4;
262 static void minmax_xy(
int np, plstruct *plstr,
int *ix1,
int *ix2,
int *iy1,
269 *ix1 = plstr[0].x - 1;
270 *ix2 = plstr[0].x - 1;
271 *iy1 = plstr[0].y - 1;
272 *iy2 = plstr[0].y - 1;
273 for (i = 1; i < np; i++) {
274 *ix1 = MIN(*ix1,plstr[i].x - 1);
275 *ix2 = MAX(*ix2,plstr[i].x - 1);
276 *iy1 = MIN(*iy1,plstr[i].y - 1);
277 *iy2 = MAX(*iy2,plstr[i].y - 1);
void apclust(ap_t *ap, int np, plstruct *plstr)
Detect multiple objects from a given Plessey array.
void apfu(ap_t *ap)
Get rid of the largest contributor in an ap structure.