|
From: Gordon K. <kin...@us...> - 2004-05-02 21:37:13
|
Update of /cvsroot/teem/teem/src/gage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16513 Modified Files: gage.h scl.c sclanswer.c Log Message: added the first non-convolution-based query to gageKindScl: localized weighted median filtering, using the weights from the k00 kernel Index: gage.h =================================================================== RCS file: /cvsroot/teem/teem/src/gage/gage.h,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** gage.h 22 Apr 2004 07:19:00 -0000 1.66 --- gage.h 2 May 2004 21:37:02 -0000 1.67 *************** *** 264,270 **** gageSclCurvDir2, /* 26: "cdir2", 2nd principle curv direction: GT[3] */ gageSclFlowlineCurv,/* 27: "fc", curvature of normal streamline: GT[1] */ gageSclLast }; ! #define GAGE_SCL_ITEM_MAX 27 /* --- 264,271 ---- gageSclCurvDir2, /* 26: "cdir2", 2nd principle curv direction: GT[3] */ gageSclFlowlineCurv,/* 27: "fc", curvature of normal streamline: GT[1] */ + gageSclMedian, /* 28: "med", median filter */ gageSclLast }; ! #define GAGE_SCL_ITEM_MAX 28 /* Index: sclanswer.c =================================================================== RCS file: /cvsroot/teem/teem/src/gage/sclanswer.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** sclanswer.c 1 Mar 2004 10:19:45 -0000 1.20 --- sclanswer.c 2 May 2004 21:37:02 -0000 1.21 *************** *** 26,32 **** gage_t gmag=0, *hess, *norm, *gvec, *gten, *k1, *k2, sHess[9], curv=0; double tmpMat[9], tmpVec[3], hevec[9], heval[3]; - gage_t len, gp1[3], gp2[3], *nPerp, nProj[9], ncTen[9]; double T, N, D; /* convenience pointers for work below */ --- 26,35 ---- gage_t gmag=0, *hess, *norm, *gvec, *gten, *k1, *k2, sHess[9], curv=0; double tmpMat[9], tmpVec[3], hevec[9], heval[3]; gage_t len, gp1[3], gp2[3], *nPerp, nProj[9], ncTen[9]; double T, N, D; + #define FD_MEDIAN_MAX 16 + int fd, nidx, xi, yi, zi; + gage_t *fw, iv3wght[2*FD_MEDIAN_MAX*FD_MEDIAN_MAX*FD_MEDIAN_MAX], + wghtSum, wght; /* convenience pointers for work below */ *************** *** 209,212 **** --- 212,249 ---- pvl->directAnswer[gageSclFlowlineCurv][0] = sqrt(ELL_3M_FROB(ncTen)); } + if (GAGE_QUERY_ITEM_TEST(pvl->query, gageSclMedian)) { + /* this item is currently a complete oddball in that it does not + benefit from anything done in the "filter" stage, which is in + fact a waste of time if the query consists only of this item */ + fd = GAGE_FD(ctx); + if (fd > FD_MEDIAN_MAX) { + fprintf(stderr, "%s: PANIC: current filter diameter = %d " + "> FD_MEDIAN_MAX = %d\n", me, fd, FD_MEDIAN_MAX); + exit(1); + } + fw = ctx->fw + fd*3*gageKernel00; + /* HEY: this needs some optimization help */ + wghtSum = 0; + nidx = 0; + for (xi=0; xi<fd; xi++) { + for (yi=0; yi<fd; yi++) { + for (zi=0; zi<fd; zi++) { + iv3wght[0 + 2*nidx] = pvl->iv3[nidx]; + iv3wght[1 + 2*nidx] = fw[xi + 0*fd]*fw[yi + 1*fd]*fw[zi + 2*fd]; + wghtSum += iv3wght[1 + 2*nidx]; + nidx++; + } + } + } + qsort(iv3wght, fd*fd*fd, 2*sizeof(gage_t), nrrdValCompare[gage_nrrdType]); + wght = 0; + for (nidx=0; nidx<fd*fd*fd; nidx++) { + wght += iv3wght[1 + 2*nidx]; + if (wght > wghtSum/2) { + break; + } + } + pvl->directAnswer[gageSclMedian][0] = iv3wght[0 + 2*nidx]; + } return; } Index: scl.c =================================================================== RCS file: /cvsroot/teem/teem/src/gage/scl.c,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** scl.c 28 Feb 2004 17:01:53 -0000 1.36 --- scl.c 2 May 2004 21:37:02 -0000 1.37 *************** *** 62,66 **** {gageSclCurvDir1, 3, 2, {gageSclGeomTens, gageSclK1, gageSclK2, -1, -1}, -1, -1}, {gageSclCurvDir2, 3, 2, {gageSclGeomTens, gageSclK1, gageSclK2, -1, -1}, -1, -1}, ! {gageSclFlowlineCurv, 1, 2, {gageSclGeomTens, -1, -1, -1, -1}, -1, -1} }; --- 62,67 ---- {gageSclCurvDir1, 3, 2, {gageSclGeomTens, gageSclK1, gageSclK2, -1, -1}, -1, -1}, {gageSclCurvDir2, 3, 2, {gageSclGeomTens, gageSclK1, gageSclK2, -1, -1}, -1, -1}, ! {gageSclFlowlineCurv, 1, 2, {gageSclGeomTens, -1, -1, -1, -1}, -1, -1}, ! {gageSclMedian, 1, 0, {-1, -1, -1, -1, -1}, -1, -1} }; *************** *** 95,99 **** "1st curvature direction", "2nd curvature direction", ! "flowline curvature" }; --- 96,101 ---- "1st curvature direction", "2nd curvature direction", ! "flowline curvature", ! "median" }; *************** *** 128,132 **** "1st principal curvature direction", "2nd principal curvature direction", ! "curvature of normal streamline" }; --- 130,135 ---- "1st principal curvature direction", "2nd principal curvature direction", ! "curvature of normal streamline", ! "median of iv3 cache (not weighted by any filter (yet))" }; *************** *** 161,165 **** gageSclCurvDir1, gageSclCurvDir2, ! gageSclFlowlineCurv }; --- 164,169 ---- gageSclCurvDir1, gageSclCurvDir2, ! gageSclFlowlineCurv, ! gageSclMedian }; *************** *** 192,195 **** --- 196,200 ---- #define GS_C2 gageSclCurvDir2 #define GS_FC gageSclFlowlineCurv + #define GS_MD gageSclMedian char *************** *** 224,227 **** --- 229,233 ---- "cdir2", "c dir2", "curvdir2", "curv dir2", "curvature direction 2", "fc", "flowlinecurv", "flowline curv", "flowline curvature", + "med", "median", "" }; *************** *** 256,260 **** GS_C1, GS_C1, GS_C1, GS_C1, GS_C1, GS_C2, GS_C2, GS_C2, GS_C2, GS_C2, ! GS_FC, GS_FC, GS_FC, GS_FC }; --- 262,267 ---- GS_C1, GS_C1, GS_C1, GS_C1, GS_C1, GS_C2, GS_C2, GS_C2, GS_C2, GS_C2, ! GS_FC, GS_FC, GS_FC, GS_FC, ! GS_MD, GS_MD }; |