diff --git a/floatimg.h b/floatimg.h index da8639b..7d207b9 100644 --- a/floatimg.h +++ b/floatimg.h @@ -4,7 +4,7 @@ * http://la.buvette.org/photos/cumul */ -#define FIMG_VERSION 152 +#define FIMG_VERSION 153 /* * in memory descriptor @@ -124,7 +124,7 @@ int fimg_binarize(FloatImg *pimg, int notused); int fimg_trinarize(FloatImg *pimg, int notused); /* module sfx3.c */ - +int fimg_crump_hard(FloatImg *src, FloatImg *dst, float kval, int notused); /* module sfx4.c */ int fimg_sfx_triplemul(FloatImg *s, FloatImg *d, int notused); diff --git a/funcs/Makefile b/funcs/Makefile index 5e2b2dd..2a0d439 100644 --- a/funcs/Makefile +++ b/funcs/Makefile @@ -7,7 +7,8 @@ COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=0 DEPS = ../floatimg.h Makefile OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \ - fimg-libpnm.o rampes.o sfx0.o sfx1.o sfx2.o sfx4.o \ + fimg-libpnm.o rampes.o \ + sfx0.o sfx1.o sfx2.o sfx3.o sfx4.o \ geometry.o rotate.o fimg-openexr.o \ equalize.o fimg-fits.o saturation.o histogram.o \ hsv.o classif.o contour2x2.o qsortrgb.o exporter.o \ @@ -99,6 +100,9 @@ sfx1.o: sfx1.c $(DEPS) sfx2.o: sfx2.c $(DEPS) gcc $(COPT) -c $< +sfx3.o: sfx3.c $(DEPS) + gcc $(COPT) -c $< + sfx4.o: sfx4.c $(DEPS) gcc $(COPT) -c $< diff --git a/funcs/sfx3.c b/funcs/sfx3.c new file mode 100644 index 0000000..31ebd90 --- /dev/null +++ b/funcs/sfx3.c @@ -0,0 +1,52 @@ +/* + * FLOATIMG - a kluge from tTh + * --------------------------- + * + * some strange effects on floating pictures, made in + * the batcave of "Le Bib", in Montpellier. + */ + + +#include +#include +#include + +#include "../floatimg.h" + +extern int verbosity; + +/* -------------------------------------------------------------- */ +int fimg_crump_hard(FloatImg *src, FloatImg *dst, float kval, int notused) +{ +float halfval; +float rgb[3]; +int x, y, foo; + +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( %p %p %f 0x%04x )\n", __func__, + src, dst, kval, notused); +#endif + +halfval = fimg_get_maxvalue(src) / 2.0; +if (verbosity) { + fprintf(stderr, "%s: halfval=%f\n", __func__, halfval); + } + +for (y=0; yheight; y++) { + for (x=0; xwidth; x++) { + foo = fimg_get_rgb(src, x, y, rgb); + if (foo) return foo; + + if (rgb[0] > halfval) rgb[0] /= 2.0; + if (rgb[1] > halfval) rgb[1] /= 2.0; + if (rgb[2] > halfval) rgb[2] /= 2.0; + + foo = fimg_put_rgb(dst, x, y, rgb); + if (foo) return foo; + } + } + +return 0; +} +/* -------------------------------------------------------------- */ + diff --git a/funcs/sfx4.c b/funcs/sfx4.c index 8366167..717b15f 100644 --- a/funcs/sfx4.c +++ b/funcs/sfx4.c @@ -21,7 +21,7 @@ int x, y, foo; float in[3], out[3]; #if DEBUG_LEVEL -fprintf(stderr, ">>> %s ( %p 0x%04x )\n", __func__, img, notused); +fprintf(stderr, ">>> %s ( %p %p 0x%04x )\n", __func__, src, dst, notused); #endif for (y=0; yheight; y++) { diff --git a/tools/fimgfx.c b/tools/fimgfx.c index 974facb..41cf254 100644 --- a/tools/fimgfx.c +++ b/tools/fimgfx.c @@ -93,9 +93,9 @@ int foo; fprintf(stderr, ">>> %s ( %p %p %f )\n", __func__, S, D, kf); #endif -foo = fimg_classif_trial(S, D, kf, 0); +foo = fimg_crump_hard(S, D, kf, 0); if (foo) { - fprintf(stderr, "%s error %d classif_trial %p\n", __func__, + fprintf(stderr, "%s error %d experiment %p\n", __func__, foo, S); return -98; }