|
From: <kin...@us...> - 2024-07-08 23:37:15
|
Revision: 7187
http://sourceforge.net/p/teem/code/7187
Author: kindlmann
Date: 2024-07-08 23:37:12 +0000 (Mon, 08 Jul 2024)
Log Message:
-----------
isolated a case where single fit is bad
Modified Paths:
--------------
teem/trunk/src/limn/lpu_cbfit.c
teem/trunk/src/limn/splineFit.c
teem/trunk/src/limn/test/02-test-fs.sh
teem/trunk/src/limn/test/03-single.sh
Modified: teem/trunk/src/limn/lpu_cbfit.c
===================================================================
--- teem/trunk/src/limn/lpu_cbfit.c 2024-07-08 22:33:25 UTC (rev 7186)
+++ teem/trunk/src/limn/lpu_cbfit.c 2024-07-08 23:37:12 UTC (rev 7187)
@@ -35,7 +35,7 @@
Nrrd *_nin, *nin;
double *xy, deltaThresh, psi, cangle, epsilon, nrpIota, time0, dtime, scale, nrpCap,
- synthPow;
+ synthPow, fitSingleTT[4];
unsigned int size0, size1, ii, synthNum, pNum, nrpIterMax;
int loop, petc, verbose, tvt[4], fitSingleLoHi[2];
char *synthOut, buff[AIR_STRLEN_SMALL + 1];
@@ -91,11 +91,18 @@
hestOptAdd_1_Double(&hopt, "cap", "cap", &nrpCap, buff,
"nrp cap parameterization change");
hestOptAdd_2_Int(&hopt, "fs", "loi hii", fitSingleLoHi, "-1 -1",
- "(if loi is >= 0): just do a single call to limnCbfSingle and "
+ "(if loi is >= 0) just do a single call to limnCbfSingle and "
"quit, using the -i input points, and fitting a spline between "
"the loi and hii indices given here. A negative hii will be "
"incremented by the number of points, so -1 works to indicate "
"the last point.");
+ hestOptAdd_4_Double(&hopt, "fstt", "T1x T1y T2x T2y", fitSingleTT, "0 0 0 0",
+ "(if non-zero): help out call to limnCbfSingle by giving these "
+ "vectors for T1 (outgoing from V0) and T2 (incoming to V3) "
+ "tangents, so they are not estimated from the data. If this is "
+ "used; V0 and V3 are set as the first and last points (there "
+ "is currently no ability to set only some of the 4 vector "
+ "args to limnCbfSingle)");
hestOptAdd_Flag(&hopt, "petc", &petc, "(Press Enter To Continue) ");
/*
hestOptAdd_1_String(&hopt, NULL, "output", &out, NULL, "output nrrd filename");
@@ -258,7 +265,21 @@
/* re-using the logic from the TVT case above */
unsigned int loi = AIR_UINT(AIR_MOD(fitSingleLoHi[0], pnum));
unsigned int hii = AIR_UINT(AIR_MOD(fitSingleLoHi[1], pnum));
- if (limnCbfSingle(&seg, NULL, NULL, NULL, NULL, fctx, lpnt, loi, hii)) {
+ double _V0[2], _V3[2];
+ const double *V0, *T1, *T2, *V3;
+ if (ELL_4V_LEN(fitSingleTT)) {
+ /* help out limnCbfSingle with specific V,T,T,V */
+ ELL_2V_COPY(_V0, lpnt->pp + 0 + 2 * 0);
+ V0 = _V0;
+ ELL_2V_COPY(_V3, lpnt->pp + 0 + 2 * (pnum - 1));
+ V3 = _V3;
+ T1 = fitSingleTT + 0;
+ T2 = fitSingleTT + 2;
+ } else {
+ /* no help will be given */
+ V0 = T1 = T2 = V3 = NULL;
+ }
+ if (limnCbfSingle(&seg, V0, T1, T2, V3, fctx, lpnt, loi, hii)) {
airMopAdd(mop, err = biffGetDone(LIMN), airFree, airMopAlways);
fprintf(stderr, "%s: trouble doing single segment fit:\n%s", me, err);
airMopError(mop);
Modified: teem/trunk/src/limn/splineFit.c
===================================================================
--- teem/trunk/src/limn/splineFit.c 2024-07-08 22:33:25 UTC (rev 7186)
+++ teem/trunk/src/limn/splineFit.c 2024-07-08 23:37:12 UTC (rev 7187)
@@ -1194,7 +1194,7 @@
printf("converged! with maxdist %g @ %u (big %d)\n", fctx->distMax,
fctx->distMaxIdx, fctx->distBig);
} else if (!fctx->distBig) {
- printf("NICE small dist %g (<%g) @ %u\n", fctx->distMax, fctx->epsilon,
+ printf("NICE small dist %g (<%g) @ %u (big 0)\n", fctx->distMax, fctx->epsilon,
fctx->distMaxIdx);
} else {
printf("hit nrp itermax %u; maxdist %g @ %u (big %d)\n", fctx->nrpIterMax,
Modified: teem/trunk/src/limn/test/02-test-fs.sh
===================================================================
--- teem/trunk/src/limn/test/02-test-fs.sh 2024-07-08 22:33:25 UTC (rev 7186)
+++ teem/trunk/src/limn/test/02-test-fs.sh 2024-07-08 23:37:12 UTC (rev 7187)
@@ -32,8 +32,8 @@
# https://devmanual.gentoo.org/tools-reference/bash/
unset UNRRDU_QUIET_QUIT
-IN=pointy.txt
-#IN=circ.txt
+IN=circ.txt
+#IN=pointy.txt
N=$(cat $IN | wc -l | xargs echo)
BIN=900
@@ -47,9 +47,9 @@
for LO in $(seq 0 $((N-1))); do
echo $LO
- HI=$((LO+7))
+ HI=$((LO+20))
LOO=$(printf %02d $LO)
- CMD="./lpu cbfit -i $IN -loop -scl 3 -psi 1000 -fs $LO $HI -v 0 -eps 0.3"
+ CMD="./lpu cbfit -i $IN -loop -scl 0 -psi 1000 -fs $LO $HI -v 0 -eps 0.3"
echo "==================== $LO $HI --> test-$LOO.png : $CMD"
eval $CMD 2>&1 > log-$LOO.txt
# cat log-$LOO.txt
Modified: teem/trunk/src/limn/test/03-single.sh
===================================================================
--- teem/trunk/src/limn/test/03-single.sh 2024-07-08 22:33:25 UTC (rev 7186)
+++ teem/trunk/src/limn/test/03-single.sh 2024-07-08 23:37:12 UTC (rev 7187)
@@ -33,29 +33,32 @@
# https://devmanual.gentoo.org/tools-reference/bash/
unset UNRRDU_QUIET_QUIT
-# why changing this from 200 to 400 to 800 can significantly change the fit
-# because the nrp parms that make sense for a small number of points don't work great
-# for a huge number of points
-N=100
+# why changing N can significantly change the fit:
+# because the nrp parms that make sense for a small number of points don't work great
+# for a huge number of points
-echo "-0.7 0.7
-2 0.7
-0 0.7
-0.7 -0.7" | unu 2op x - 1 | unu 2op + - 0.0 | ./lpu cbfit -i - -synthn $N -sup 1 -syntho xy-0.txt
-junk xy-0.txt
+# Good debugging test case, N=18 is a bad fit, N=19 is a perfect fit
+N=18
-./lpu cbfit -i xy-0.txt -scl 0 -fs 0 -1 -v 0 -psi 1000000000 -eps 0.001 -nim 8000 -deltathr 0.0001 -iota 0.01 -cap 10 2>&1 > log.txt
+echo "-0.5 0.5
+ 2.0 0.5
+-0.5 0.0
+ 0.5 -0.5" | unu 2op x - 1 | unu 2op + - 0.0 | ./lpu cbfit -i - -synthn $N -sup 1 -syntho xy-inn-$N.txt
+# junk xy-inn-$N.txt
+
+#./lpu cbfit -i xy-inn-$N.txt -scl 0 -fs 0 -1 -v 0 -psi 1000000000 -eps 0.001 -nim 8000 -deltathr 0.0001 -iota 0.01 -cap 10 2>&1 > log.txt
+./lpu cbfit -i xy-inn-$N.txt -scl 0 -fs 0 -1 -v 3 -psi 1000000000 -fstt 1 0 -0.8944 0.4472 -nim 400 -deltathr 0.000000000001 2>&1 > log.txt
cat log.txt; junk log.txt
-tail -n 4 log.txt | ./lpu cbfit -i - -synthn $N -sup 1 -syntho xy-1.txt
-junk xy-1.txt
+tail -n 4 log.txt | ./lpu cbfit -i - -synthn $N -sup 1 -syntho xy-out-$N.txt
+junk xy-out-$N.txt
BIN=500
-for I in 0 1; do
- unu jhisto -i xy-$I.txt -min -1.1 1.1 -max 1.1 -1.1 -b $BIN $BIN |
- unu quantize -b 8 -max 1 -o xy-$I.png
+for X in inn out; do
+ unu jhisto -i xy-$X-$N.txt -min -1.1 1.1 -max 1.1 -1.1 -b $BIN $BIN |
+ unu quantize -b 8 -max 1 -o xy-$X.png
done
-unu join -i xy-{1,0,1}.png -a 0 -incr |
+unu join -i xy-{out,inn,out}.png -a 0 -incr |
unu resample -s = x2 x2 -k box -o tmp.png
open tmp.png
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|