00001
00002
00003
00004
00005
00006
00007 #include <stdio.h>
00008 #include "imcore.h"
00009 #include "util.h"
00010
00011 void apline(ap_t *ap, float dat[], int conf[], float smoothed[],
00012 float smoothedc[], int j, unsigned char *bpm) {
00013 int i,i1,loop,nn;
00014 int is;
00015 int ip;
00016 int ib;
00017 float i2compare,icompare;
00018 unsigned char *mflag;
00019
00020 i2compare = ap->thresh;
00021 icompare = i2compare * ap->multiply;
00022 mflag = ap->mflag;
00023
00024 for (i = 0; i < ap->lsiz; i++) {
00025 if (smoothedc[i] > icompare && conf[i] != 0) {
00026
00027
00028
00029 is = ap->lastline[i];
00030 ip = ap->lastline[i + 1];
00031 if (ip == 0) {
00032
00033
00034
00035 if (is == 0) {
00036
00037
00038
00039 ip = ap->pstack[ap->ipstack++];
00040 ap->parent[ip].first = ap->bstack[ap->ibstack];
00041 ap->parent[ip].pnop = 0;
00042 ap->parent[ip].pnbp = 0;
00043 ap->parent[ip].growing = 0;
00044 if (j == 0)
00045
00046
00047
00048 ap->parent[ip].touch = 1;
00049 else
00050 ap->parent[ip].touch = 0;
00051
00052
00053
00054 if (ip > ap->maxip)
00055 ap->maxip = ip;
00056 } else {
00057
00058
00059
00060 ip = is;
00061 }
00062 } else if ((ip > 0 && is > 0) && (ip != is)) {
00063
00064
00065
00066 ap->blink[ap->parent[ip].last] = ap->parent[is].first;
00067
00068
00069
00070 ap->parent[ip].last = ap->parent[is].last;
00071 ap->parent[ip].pnop += ap->parent[is].pnop;
00072 ap->parent[ip].pnbp += ap->parent[is].pnbp;
00073
00074
00075
00076 ib = ap->parent[is].first;
00077 loop = 1;
00078 while (loop) {
00079 i1 = ap->plessey[ib].x;
00080 if (ap->lastline[i1 + 1] == is)
00081 ap->lastline[i1 + 1] = ip;
00082 if (ap->parent[is].last == ib)
00083 loop = 0;
00084 else
00085 ib = ap->blink[ib];
00086 }
00087
00088
00089
00090 ap->parent[is].pnop = -1;
00091 ap->parent[is].pnbp = -1;
00092
00093
00094
00095 ap->pstack[--ap->ipstack] = is;
00096 }
00097
00098
00099
00100 ib = ap->bstack[ap->ibstack++];
00101
00102
00103
00104 if (ap->parent[ip].pnop > 0)
00105 ap->blink[ap->parent[ip].last] = ib;
00106
00107
00108
00109 ap->parent[ip].last = ib;
00110
00111
00112
00113 ap->plessey[ib].x = i;
00114 ap->plessey[ib].y = j;
00115 ap->plessey[ib].z = dat[i];
00116 nn = j*ap->lsiz + i;
00117 if (mflag[nn] != MF_SATURATED)
00118 ap->plessey[ib].zsm = MIN(ap->saturation,smoothed[i]);
00119 else
00120 ap->plessey[ib].zsm = ap->saturation;
00121 mflag[nn] = MF_POBJPIX;
00122
00123
00124
00125 ap->parent[ip].pnop++;
00126 if (bpm != NULL)
00127 ap->parent[ip].pnbp += bpm[i];
00128
00129
00130
00131 ap->lastline[i + 1] = ip;
00132
00133 } else {
00134
00135
00136
00137 ap->lastline[i + 1] = 0;
00138 }
00139 }
00140
00141
00142
00143
00144 if(ap->lastline[1] > 0 )
00145 ap->parent[ap->lastline[1]].touch |= 2;
00146 if(ap->lastline[ap->lsiz] > 0)
00147 ap->parent[ap->lastline[ap->lsiz]].touch |= 4;
00148 }
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160