better testing of interpolate func

This commit is contained in:
tonton Th 2020-02-16 23:16:38 +01:00
parent e454404f97
commit 219bd36cc2
2 changed files with 28 additions and 15 deletions

41
lib/t.c
View File

@ -53,7 +53,9 @@ return 0;
int essai_interpolate(int k)
{
FloatImg A, B, C;
int foo;
int foo, idx;
char ligne[200];
float fval;
foo = fimg_create(&A, WI, HI, FIMG_TYPE_RGB);
if (foo) {
@ -75,14 +77,21 @@ if (foo) {
return foo;
}
foo = fimg_interpolate(&A, &B, &C, 0.5);
if (foo) {
fprintf(stderr, "%s err interpolate %d\n", __func__, foo);
return foo;
#define NB 16
for (idx=0; idx<NB; idx++) {
fval = (float)idx / (float)NB;
if (verbosity) fprintf(stderr, "%4d %f\n", idx, fval);
foo = fimg_interpolate(&A, &B, &C, fval);
if (foo) {
fprintf(stderr, "%s err interpolate %d\n", __func__, foo);
return foo;
}
sprintf(ligne, "polate-%02d.pnm", idx);
foo = fimg_save_as_pnm(&C, ligne, 0);
}
foo = fimg_save_as_pnm(&C, "interpolate.pnm", 0);
/*
$ convert -delay 10 polate-* foo.gif ; animate foo.gif
*/
fimg_destroy(&A); fimg_destroy(&B); fimg_destroy(&C);
return 0;
@ -223,19 +232,23 @@ while ((opt = getopt(argc, argv, "gn:v")) != -1) {
case 'g': gray++; break;
case 'n': foo=atoi(optarg); break;
case 'v': verbosity++; break;
default:
fprintf(stderr, "%s: oh, %c is a bad opt.\n",
argv[0], opt);
exit(5);
}
}
if (verbosity) fimg_print_version(0);
foo = essai_normalize();
fprintf(stderr, "retour essai normalize -> %d\n", foo);
// foo = essai_normalize();
// fprintf(stderr, "retour essai normalize -> %d\n", foo);
foo = essai_contraste("quux.fimg");
fprintf(stderr, "retour essai contraste -> %d\n", foo);
// foo = essai_contraste("quux.fimg");
// fprintf(stderr, "retour essai contraste -> %d\n", foo);
foo = essai_clone_et_copy(0);
fprintf(stderr, "retour essai clone'n'copy -> %d\n", foo);
// foo = essai_clone_et_copy(0);
// fprintf(stderr, "retour essai clone'n'copy -> %d\n", foo);
foo = essai_interpolate(0);
fprintf(stderr, "retour essai interpolate -> %d\n", foo);

View File

@ -84,7 +84,7 @@ switch (action) {
case OP_SUB:
foo = fimg_sub_3(A, B, D); break;
case OP_MIX:
if (verbosity) fprintf(stderr, "%s: fvalue is %f\n",
if (verbosity) fprintf(stderr, "%s:mix: fvalue is %f\n",
__func__, global_fvalue);
foo = fimg_interpolate(A, B, D, global_fvalue);
break;