Compare commits

...

5 Commits

Author SHA1 Message Date
tonton Th
b1ae9f31ed tracking a bug... 2020-02-17 07:40:06 +01:00
tonton Th
d0b7ddfd91 nice xperimental option 2020-02-17 01:27:33 +01:00
tonton Th
6a2b37d4e3 minor bug spotted with DEBUG_LEVEL=1 2020-02-16 23:50:44 +01:00
tonton Th
219bd36cc2 better testing of interpolate func 2020-02-16 23:16:38 +01:00
tonton Th
e454404f97 better verbose display in fimgops 2020-02-16 21:28:20 +01:00
7 changed files with 76 additions and 27 deletions

View File

@ -2,7 +2,7 @@
* floatimg.h * floatimg.h
*/ */
#define FIMG_VERSION 91 #define FIMG_VERSION 92
/* /*
* in memory descriptor * in memory descriptor

View File

@ -15,7 +15,7 @@ extern int verbosity; /* must be declared around main() */
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
int fimg_images_compatible(FloatImg *a, FloatImg *b) int fimg_images_compatible(FloatImg *a, FloatImg *b)
{ {
#if DEBUG_LEVEL #if DEBUG_LEVEL > 1
fprintf(stderr, ">>> %s ( %p %p )\n", __func__, a, b); fprintf(stderr, ">>> %s ( %p %p )\n", __func__, a, b);
#endif #endif

View File

@ -112,7 +112,7 @@ int foo, nbre;
FimgFileHead filehead; FimgFileHead filehead;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %-25s ( '%s' %p )\n", __func__, fname, head); fprintf(stderr, ">>> %-25s ( '%s' %p )\n", __func__, fname, where);
#endif #endif
if (NULL==(fp = fopen(fname, "r"))) { if (NULL==(fp = fopen(fname, "r"))) {

View File

@ -41,15 +41,20 @@ int fimg_interpolate(FloatImg *s1, FloatImg *s2, FloatImg *d, float coef)
{ {
int foo; int foo;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %p %f )\n", __func__,
s1, s2, d, coef);
#endif
foo = fimg_images_compatible(s1, s2); foo = fimg_images_compatible(s1, s2);
if (foo) { if (foo) {
fprintf(stderr, "compat -> %d\n", foo); fprintf(stderr, "compat s1 s2 -> %d\n", foo);
return foo; return foo;
} }
foo = fimg_images_compatible(s1, d); foo = fimg_images_compatible(s1, d);
if (foo) { if (foo) {
fprintf(stderr, "compat -> %d\n", foo); fprintf(stderr, "compat s1 d -> %d\n", foo);
return foo; return foo;
} }

35
lib/t.c
View File

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

View File

@ -19,7 +19,8 @@ typedef struct {
int nbarg; int nbarg;
} Fx; } Fx;
enum fxid { Fx_cos01, Fx_cos010, Fx_pow2, Fx_sqrt, Fx_gray0, Fx_halfsz0 }; enum fxid { Fx_cos01=5, Fx_cos010, Fx_pow2, Fx_sqrt, Fx_gray0, Fx_halfsz0,
Fx_xper };
Fx fx_list[] = { Fx fx_list[] = {
{ "cos01", Fx_cos01, 0 }, { "cos01", Fx_cos01, 0 },
@ -28,6 +29,7 @@ Fx fx_list[] = {
{ "sqrt", Fx_sqrt, 0 }, { "sqrt", Fx_sqrt, 0 },
{ "gray0", Fx_gray0, 0 }, { "gray0", Fx_gray0, 0 },
{ "halfsz0", Fx_halfsz0, 0 }, { "halfsz0", Fx_halfsz0, 0 },
{ "xper", Fx_xper, 0 },
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
@ -42,15 +44,39 @@ fprintf(stderr, ">>> %s ( '%s' )\n", __func__, txt);
#endif #endif
for (n=0, fx=fx_list; fx->name; fx++, n++) { for (n=0, fx=fx_list; fx->name; fx++, n++) {
#if DEBUG_LEVEL #if DEBUG_LEVEL > 1
fprintf(stderr, "-> %3d %s\n", n, fx->name); fprintf(stderr, "-> %3d %s\n", n, fx->name);
#endif #endif
if (!strcmp(fx->name, txt)) { if (!strcmp(fx->name, txt)) {
return n; return n;
} }
} }
return -1; /* NOT FOUND */
}
/* --------------------------------------------------------------------- */
int do_experiment(FloatImg *S, FloatImg *D, float kf)
{
int foo;
return -1; #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %f )\n", __func__, S, D, kf);
#endif
foo = fimg_copy_data(S, D);
if (foo) {
fprintf(stderr, "%s err %d copy data %p -> %p\n", __func__,
foo, S, D);
return -98;
}
foo = fimg_killcolors_a(D, kf);
if (foo) {
fprintf(stderr, "%s err %d killcolors %p %f\n", __func__,
foo, S, kf);
return -98;
}
return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
static void help(int lvl) static void help(int lvl)
@ -113,6 +139,10 @@ switch (act) {
fimg_to_gray(&src); fimg_copy_data(&src, &dest); fimg_to_gray(&src); fimg_copy_data(&src, &dest);
break; break;
case Fx_xper:
do_experiment(&src, &dest, maxval); break;
case Fx_halfsz0: case Fx_halfsz0:
fprintf(stderr, "not implemented\n"); fprintf(stderr, "not implemented\n");
return -3; return -3;

View File

@ -84,8 +84,8 @@ switch (action) {
case OP_SUB: case OP_SUB:
foo = fimg_sub_3(A, B, D); break; foo = fimg_sub_3(A, B, D); break;
case OP_MIX: case OP_MIX:
if (verbosity) fprintf(stderr, "fvalue is %f\n", if (verbosity) fprintf(stderr, "%s:mix: fvalue is %f\n",
global_fvalue); __func__, global_fvalue);
foo = fimg_interpolate(A, B, D, global_fvalue); foo = fimg_interpolate(A, B, D, global_fvalue);
break; break;
case OP_MUL: case OP_MUL:
@ -95,6 +95,7 @@ switch (action) {
case OP_MAXI: case OP_MAXI:
foo = fimg_minimum(A, B, D); break; foo = fimg_minimum(A, B, D); break;
default: default:
fprintf(stderr, "fscking action #%d\n", action);
foo = -99; break; foo = -99; break;
} }
@ -147,7 +148,7 @@ if ((foo=fimg_create_from_dump(argv[optind+1], &srcB))) {
exit(3); exit(3);
} }
if (verbosity) { /* please, debug me */ if (verbosity > 1) { /* please, debug me */
fimg_describe(&srcA, argv[optind]); fimg_describe(&srcA, argv[optind]);
fimg_describe(&srcB, argv[optind+1]); fimg_describe(&srcB, argv[optind+1]);
} }