Browse Source

* Reactivate full ED analysis (raster FS, raster JaJuNi, serpentine

Ostromoukhov and serpentine optimum) as mode 5.
  * Add a script to perform mode 5 on a directory's contents.


git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/research@2278 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 16 years ago
parent
commit
57cd9a2b83
2 changed files with 103 additions and 78 deletions
  1. +75
    -78
      2008-displacement/main.c
  2. +28
    -0
      2008-displacement/study-5.sh

+ 75
- 78
2008-displacement/main.c View File

@@ -511,21 +511,27 @@ static float *dbs(float const *src, float const *orig,
} }


static void study(float const *src, float const *dest, static void study(float const *src, float const *dest,
float sigma, float precision)
float sigma, float precision, float fdx, float fdy)
{ {
# define Z 3 # define Z 3
float mat[NN][NN];
float mat[NN][NN], mat2[NN][NN];
float *tmp, *tmp2; float *tmp, *tmp2;
float e, e0, best = 1., fx = -1., fy = -1., step = 2., bfx = 0., bfy = 0.;
float e, e0, e1;
float best = 1., fx = -1., fy = -1., step = 2., bfx = 0., bfy = 0.;
int dx, dy; int dx, dy;


makegauss(mat, sigma, 0., 0.); makegauss(mat, sigma, 0., 0.);
tmp = gauss(src, mat); tmp = gauss(src, mat);
tmp2 = gauss(dest, mat);


tmp2 = gauss(dest, mat);
e0 = dist(tmp, tmp2, 1.); e0 = dist(tmp, tmp2, 1.);
free(tmp2); free(tmp2);


makegauss(mat2, sigma, fdx, fdy);
tmp2 = gauss(dest, mat2);
e1 = dist(tmp, tmp2, 1.);
free(tmp2);

while(step > precision) while(step > precision)
{ {
for(dy = 0; dy <= Z; dy++) for(dy = 0; dy <= Z; dy++)
@@ -550,8 +556,8 @@ static void study(float const *src, float const *dest,


free(tmp); free(tmp);


printf("E = %g E_min = %g dx = %g dy = %g\n",
1000 * e0, 1000 * best, fx, fy);
printf("E = %g E_fast = %g E_min = %g dx = %g dy = %g\n",
1000. * e0, 1000. * e1, 1000. * best, fx, fy);
fflush(stdout); fflush(stdout);
} }


@@ -575,6 +581,7 @@ static void usage(char *argv[])
fprintf(stderr, " -2 <src1> <src2> raster FS displacement study on blends of src1 and src2\n"); fprintf(stderr, " -2 <src1> <src2> raster FS displacement study on blends of src1 and src2\n");
fprintf(stderr, " -3 <src> quick (a,b,c,d) ED kernel analysis on src\n"); fprintf(stderr, " -3 <src> quick (a,b,c,d) ED kernel analysis on src\n");
fprintf(stderr, " -4 <src> exhaustive (a,b,c,d) ED kernel analysis on src\n"); fprintf(stderr, " -4 <src> exhaustive (a,b,c,d) ED kernel analysis on src\n");
fprintf(stderr, " -5 <src> exhaustive displacement study on src\n");
} }


int main(int argc, char *argv[]) int main(int argc, char *argv[])
@@ -600,12 +607,16 @@ int main(int argc, char *argv[])
if(!src) if(!src)
return 2; return 2;


printf("### mode %i on `%s' ###\n", mode, argv[2]);

switch(mode) switch(mode)
{ {
case 1: case 1:
{ {
float *dest = ed(src, false, 7, 0, 1, 3, 5, 0, 0, 0, 0, 0, 0, 0);
study(src, dest, 1.2, 0.001);
float *dest = ed(src, false, 7, 0,
0, 3, 5, 1, 0,
0, 0, 0, 0, 0);
study(src, dest, 1.2, 0.001, .16, .28);
free(dest); free(dest);
free(src); free(src);
} }
@@ -624,8 +635,10 @@ int main(int argc, char *argv[])
for(i = 0; i <= 100; i++) for(i = 0; i <= 100; i++)
{ {
tmp = merge(src, src2, (float)i / 100.); tmp = merge(src, src2, (float)i / 100.);
dest = ed(tmp, false, 7, 0, 1, 3, 5, 0, 0, 0, 0, 0, 0, 0);
study(tmp, dest, 1.2, 0.001);
dest = ed(tmp, false, 7, 0,
0, 3, 5, 1, 0,
0, 0, 0, 0, 0);
study(tmp, dest, 1.2, 0.001, .16, .28);
free(dest); free(dest);
free(tmp); free(tmp);
} }
@@ -637,18 +650,19 @@ int main(int argc, char *argv[])
case 3: case 3:
case 4: case 4:
{ {
float mat0[NN][NN];
float mat[NN][NN];
float *dest, *tmp, *tmp2; float *dest, *tmp, *tmp2;
int a, b, c, d, e; int a, b, c, d, e;


makegauss(mat0, 1.2, 0, 0);
for(a = 0; a <= 16; a++)
for(b = 0; b <= 16; b++)
for(c = 0; c <= 16; c++)
for(d = 0; d <= 16; d++)
for(e = 0; e <= 16; e++)
#define TOTAL 16
makegauss(mat, 1.2, 0, 0);
for(a = 0; a <= TOTAL; a++)
for(b = 0; b <= TOTAL; b++)
for(c = 0; c <= TOTAL; c++)
for(d = 0; d <= TOTAL; d++)
for(e = 0; e <= TOTAL; e++)
{ {
if(a + b + c + d + e != 16)
if(a + b + c + d + e != TOTAL)
continue; continue;


/* Slightly shuffle our coefficients to avoid waiting until /* Slightly shuffle our coefficients to avoid waiting until
@@ -656,12 +670,12 @@ int main(int argc, char *argv[])
int a2 = a, b2 = b, c2 = c, d2 = d, e2 = e; int a2 = a, b2 = b, c2 = c, d2 = d, e2 = e;
#define SHUFFLE(p,q,n) \ #define SHUFFLE(p,q,n) \
if(p+q) { int tmp = p+q; p = (p+n) % (tmp+1); q = tmp-p; } if(p+q) { int tmp = p+q; p = (p+n) % (tmp+1); q = tmp-p; }
SHUFFLE(c2, d2, 7); SHUFFLE(b2, d2, 5);
SHUFFLE(a2, d2, 3); SHUFFLE(b2, c2, 2);
SHUFFLE(a2, e2, 3); SHUFFLE(b2, e2, 2);
SHUFFLE(a2, c2, 4); SHUFFLE(a2, b2, 6);
SHUFFLE(c2, e2, 9); SHUFFLE(d2, e2, 7);
SHUFFLE(a2, d2, 9); SHUFFLE(a2, b2, 7);
SHUFFLE(c2, d2, 777); SHUFFLE(b2, d2, 555);
SHUFFLE(a2, d2, 333); SHUFFLE(b2, c2, 222);
SHUFFLE(a2, e2, 333); SHUFFLE(b2, e2, 222);
SHUFFLE(a2, c2, 444); SHUFFLE(a2, b2, 666);
SHUFFLE(c2, e2, 999); SHUFFLE(d2, e2, 777);
SHUFFLE(a2, d2, 999); SHUFFLE(a2, b2, 777);


#if 0 #if 0
if(b2 > c2) continue; if(b2 > c2) continue;
@@ -673,17 +687,21 @@ int main(int argc, char *argv[])
//printf("K = %d,%d,%d,%d,%d ", a2, b2, c2, d2, e2); //printf("K = %d,%d,%d,%d,%d ", a2, b2, c2, d2, e2);
printf("K = %d,%d,%d,%d ", a2, c2, d2, e2); printf("K = %d,%d,%d,%d ", a2, c2, d2, e2);


dest = ed(src, false, a2, 0, b2, c2, d2, e2, 0, 0, 0, 0, 0, 0);
if(mode == 3)
dest = ed(src, false, a2, 0,
b2, c2, d2, e2, 0,
0, 0, 0, 0, 0);
if(mode == 4)
{ {
tmp = gauss(src, mat0);
tmp2 = gauss(dest, mat0);
study(src, dest, 1.2, 0.001, 0., 0.);
}
else
{
tmp = gauss(src, mat);
tmp2 = gauss(dest, mat);
printf("E = %.5g\n", 1000. * dist(tmp, tmp2, 1.)); printf("E = %.5g\n", 1000. * dist(tmp, tmp2, 1.));
free(tmp); free(tmp);
free(tmp2); free(tmp2);
} }
else
study(src, dest, 1.2, 0.001);
fflush(stdout); fflush(stdout);
free(dest); free(dest);
} }
@@ -692,6 +710,33 @@ int main(int argc, char *argv[])
} }
break; break;


case 5:
{
float *dest;

dest = ed(src, false, 7, 0,
0, 3, 5, 1, 0,
0, 0, 0, 0, 0);
study(src, dest, 1.2, 0.001, .16, .28);
free(dest);

dest = ed(src, false, 7, 5,
3, 5, 7, 5, 3,
1, 3, 5, 3, 1);
study(src, dest, 1.2, 0.001, .26, .76);
free(dest);

dest = ostromoukhov(src);
study(src, dest, 1.2, 0.001, .0, .19);
free(dest);

dest = ed(src, true, 2911, 0,
0, 1373, 3457, 2258, 0,
0, 0, 0, 0, 0);
study(src, dest, 1.2, 0.001, .0, .34);
}
break;

#if 0 #if 0
tmp = ed(src, 7, 0, 0, 3, 5, 1, 0, 0, 0, 0, 0, 0); tmp = ed(src, 7, 0, 0, 3, 5, 1, 0, 0, 0, 0, 0, 0);
//dest = dbs(src, tmp, 0., 0.); //dest = dbs(src, tmp, 0., 0.);
@@ -766,54 +811,6 @@ int main(int argc, char *argv[])
save(dest, "output.bmp"); save(dest, "output.bmp");
#endif #endif


#if 0
printf("%s: ", argv[1]);
makegauss(mat0, 1.2, 0, 0);
tmp = gauss(src, mat0);

dest = ed(src, false, 7, 0, 0, 3, 5, 1, 0, 0, 0, 0, 0, 0);
tmp2 = gauss(dest, mat0);
printf("%.5g ", 1000. * dist(tmp, tmp2, 1.));
free(tmp2);
makegauss(mat, 1.2, 0.16, 0.28);
tmp2 = gauss(dest, mat);
printf("%.5g ", 1000. * dist(tmp, tmp2, 1.));
free(tmp2);
free(dest);

dest = ed(src, false, 7, 5, 3, 5, 7, 5, 3, 1, 3, 5, 3, 1);
tmp2 = gauss(dest, mat0);
printf("%.5g ", 1000. * dist(tmp, tmp2, 1.));
free(tmp2);
makegauss(mat, 1.2, 0.26, 0.76);
tmp2 = gauss(dest, mat);
printf("%.5g ", 1000. * dist(tmp, tmp2, 1.));
free(tmp2);
free(dest);

dest = ostromoukhov(src);
tmp2 = gauss(dest, mat0);
printf("%.5g ", 1000. * dist(tmp, tmp2, 1.));
free(tmp2);
makegauss(mat, 1.2, 0.0, 0.19);
tmp2 = gauss(dest, mat);
printf("%.5g ", 1000. * dist(tmp, tmp2, 1.));
free(tmp2);
free(dest);

dest = ed(src, true, 2911, 0, 0, 1373, 3457, 2258, 0, 0, 0, 0, 0, 0);
tmp2 = gauss(dest, mat0);
printf("%.5g ", 1000. * dist(tmp, tmp2, 1.));
free(tmp2);
makegauss(mat, 1.2, 0.0, 0.34);
tmp2 = gauss(dest, mat);
printf("%.5g ", 1000. * dist(tmp, tmp2, 1.));
free(tmp2);
free(dest);

printf("\n");
#endif

#if 0 #if 0
printf("%s\n", argv[1]); printf("%s\n", argv[1]);




+ 28
- 0
2008-displacement/study-5.sh View File

@@ -0,0 +1,28 @@
#!/bin/sh

set -e

if [ ! -x ./main ]; then
make main
fi

if [ "$1" = "" ]; then
echo "Usage: $0 <directory>"
exit 1
fi

if [ ! -d "$1" ]; then
echo "$0: $1 is not a directory"
exit 1
fi

OUTPUT="$(echo "$1" | tr -d /).txt"
echo "$0: outputting to $OUTPUT"

touch "$OUTPUT"
find $1 -name '?????????????.???' | while read i; do
TMP="$(./main -5 $i)"
echo "$TMP" >> "$OUTPUT"
echo "$TMP"
done


Loading…
Cancel
Save