Compare commits

..

No commits in common. "b1ae9f31ed145ecb0f5d07cb70a03d5b9a9298a3" and "23ce4cd3375041712fe117073fff3c4b15b6fd50" have entirely different histories.

7 changed files with 27 additions and 76 deletions

View File

@ -2,7 +2,7 @@
* floatimg.h
*/
#define FIMG_VERSION 92
#define FIMG_VERSION 91
/*
* 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)
{
#if DEBUG_LEVEL > 1
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p )\n", __func__, a, b);
#endif

View File

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

View File

@ -41,28 +41,23 @@ int fimg_interpolate(FloatImg *s1, FloatImg *s2, FloatImg *d, float coef)
{
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);
if (foo) {
fprintf(stderr, "compat s1 s2 -> %d\n", foo);
fprintf(stderr, "compat -> %d\n", foo);
return foo;
}
foo = fimg_images_compatible(s1, d);
if (foo) {
fprintf(stderr, "compat s1 d -> %d\n", foo);
fprintf(stderr, "compat -> %d\n", foo);
return foo;
}
switch (s1->type) {
case FIMG_TYPE_GRAY:
gray_interpolate (s1, s2, d, coef); break;
gray_interpolate(s1, s2, d, coef); break;
case FIMG_TYPE_RGB:
rgb_interpolate (s1, s2, d, coef); break;
rgb_interpolate(s1, s2, d, coef); break;
default:
fprintf(stderr, "%s, %d is a bad type\n", __func__, s1->type);
return -18;

41
lib/t.c
View File

@ -53,9 +53,7 @@ return 0;
int essai_interpolate(int k)
{
FloatImg A, B, C;
int foo, idx;
char ligne[200];
float fval;
int foo;
foo = fimg_create(&A, WI, HI, FIMG_TYPE_RGB);
if (foo) {
@ -77,21 +75,14 @@ if (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_interpolate(&A, &B, &C, 0.5);
if (foo) {
fprintf(stderr, "%s err interpolate %d\n", __func__, foo);
return foo;
}
/*
$ convert -delay 10 polate-* foo.gif ; animate foo.gif
*/
foo = fimg_save_as_pnm(&C, "interpolate.pnm", 0);
fimg_destroy(&A); fimg_destroy(&B); fimg_destroy(&C);
return 0;
@ -232,23 +223,19 @@ 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

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

View File

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