Compare commits
5 Commits
23ce4cd337
...
b1ae9f31ed
Author | SHA1 | Date | |
---|---|---|---|
|
b1ae9f31ed | ||
|
d0b7ddfd91 | ||
|
6a2b37d4e3 | ||
|
219bd36cc2 | ||
|
e454404f97 |
@ -2,7 +2,7 @@
|
||||
* floatimg.h
|
||||
*/
|
||||
|
||||
#define FIMG_VERSION 91
|
||||
#define FIMG_VERSION 92
|
||||
|
||||
/*
|
||||
* in memory descriptor
|
||||
|
@ -15,7 +15,7 @@ extern int verbosity; /* must be declared around main() */
|
||||
/* ---------------------------------------------------------------- */
|
||||
int fimg_images_compatible(FloatImg *a, FloatImg *b)
|
||||
{
|
||||
#if DEBUG_LEVEL
|
||||
#if DEBUG_LEVEL > 1
|
||||
fprintf(stderr, ">>> %s ( %p %p )\n", __func__, a, b);
|
||||
#endif
|
||||
|
||||
|
@ -112,7 +112,7 @@ int foo, nbre;
|
||||
FimgFileHead filehead;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %-25s ( '%s' %p )\n", __func__, fname, head);
|
||||
fprintf(stderr, ">>> %-25s ( '%s' %p )\n", __func__, fname, where);
|
||||
#endif
|
||||
|
||||
if (NULL==(fp = fopen(fname, "r"))) {
|
||||
|
@ -41,23 +41,28 @@ 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 -> %d\n", foo);
|
||||
fprintf(stderr, "compat s1 s2 -> %d\n", foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
foo = fimg_images_compatible(s1, d);
|
||||
if (foo) {
|
||||
fprintf(stderr, "compat -> %d\n", foo);
|
||||
fprintf(stderr, "compat s1 d -> %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;
|
||||
|
37
lib/t.c
37
lib/t.c
@ -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) {
|
||||
#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;
|
||||
}
|
||||
|
||||
foo = fimg_save_as_pnm(&C, "interpolate.pnm", 0);
|
||||
|
||||
sprintf(ligne, "polate-%02d.pnm", idx);
|
||||
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);
|
||||
|
||||
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);
|
||||
|
@ -19,7 +19,8 @@ typedef struct {
|
||||
int nbarg;
|
||||
} 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[] = {
|
||||
{ "cos01", Fx_cos01, 0 },
|
||||
@ -28,6 +29,7 @@ Fx fx_list[] = {
|
||||
{ "sqrt", Fx_sqrt, 0 },
|
||||
{ "gray0", Fx_gray0, 0 },
|
||||
{ "halfsz0", Fx_halfsz0, 0 },
|
||||
{ "xper", Fx_xper, 0 },
|
||||
{ NULL, 0, 0 }
|
||||
};
|
||||
|
||||
@ -42,15 +44,39 @@ fprintf(stderr, ">>> %s ( '%s' )\n", __func__, txt);
|
||||
#endif
|
||||
|
||||
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);
|
||||
#endif
|
||||
if (!strcmp(fx->name, txt)) {
|
||||
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)
|
||||
@ -113,6 +139,10 @@ 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;
|
||||
|
@ -84,8 +84,8 @@ switch (action) {
|
||||
case OP_SUB:
|
||||
foo = fimg_sub_3(A, B, D); break;
|
||||
case OP_MIX:
|
||||
if (verbosity) fprintf(stderr, "fvalue is %f\n",
|
||||
global_fvalue);
|
||||
if (verbosity) fprintf(stderr, "%s:mix: fvalue is %f\n",
|
||||
__func__, global_fvalue);
|
||||
foo = fimg_interpolate(A, B, D, global_fvalue);
|
||||
break;
|
||||
case OP_MUL:
|
||||
@ -95,6 +95,7 @@ switch (action) {
|
||||
case OP_MAXI:
|
||||
foo = fimg_minimum(A, B, D); break;
|
||||
default:
|
||||
fprintf(stderr, "fscking action #%d\n", action);
|
||||
foo = -99; break;
|
||||
|
||||
}
|
||||
@ -147,7 +148,7 @@ if ((foo=fimg_create_from_dump(argv[optind+1], &srcB))) {
|
||||
exit(3);
|
||||
}
|
||||
|
||||
if (verbosity) { /* please, debug me */
|
||||
if (verbosity > 1) { /* please, debug me */
|
||||
fimg_describe(&srcA, argv[optind]);
|
||||
fimg_describe(&srcB, argv[optind+1]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user