From 02b4493659d2bd5ef1f8c9064d4b722260d4ed9b Mon Sep 17 00:00:00 2001 From: tTh Date: Mon, 1 Apr 2024 00:07:34 +0200 Subject: [PATCH] minor changes --- experiment/Makefile | 2 +- experiment/assemblage.c | 1 - experiment/cachengn.c | 10 +++++----- experiment/mnt.c | 26 +++++++++++++++++--------- experiment/movepixels.c | 14 ++++++++------ experiment/remotegrab.c | 0 6 files changed, 31 insertions(+), 22 deletions(-) create mode 100644 experiment/remotegrab.c diff --git a/experiment/Makefile b/experiment/Makefile index 5d2f5d48..caccf7a0 100644 --- a/experiment/Makefile +++ b/experiment/Makefile @@ -27,7 +27,7 @@ fimg2obj: fimg2obj.c $(DEPS) gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@ # --------------------------------------------------------- -# CACHE ENGINE +# CACHE ENGINE (wip) cachengn.o: cachengn.c cachengn.h Makefile gcc $(COPT) -c $< diff --git a/experiment/assemblage.c b/experiment/assemblage.c index a901f6f3..c83fea88 100644 --- a/experiment/assemblage.c +++ b/experiment/assemblage.c @@ -51,7 +51,6 @@ if (foo) { return -1; } - foo = fimg_export_picture(&grande, outname, 0); if (foo) { fprintf(stderr, "%s: error %d export '%s'\n", __func__, diff --git a/experiment/cachengn.c b/experiment/cachengn.c index b7e40267..4cd8b10a 100644 --- a/experiment/cachengn.c +++ b/experiment/cachengn.c @@ -36,7 +36,7 @@ int init_empty_cache(int iw, int ih, int szc, int wtfparam) { int idx; -fprintf(stderr, ">>> %s ( %d %d %d %d )\n", __func__, +fprintf(stderr, ">>> %s ( %d %d %d %d )\n", __func__, iw, ih, szc, wtfparam); /* MOLLYGUARD : don't init TWICE, please */ @@ -89,7 +89,7 @@ for (idx=0; idxwidth * img->height; -minp = 1e10, maxp = -1e10; +minp = 1e30, maxp = -1e30; for (offset=0; offsetR[offset]; if (pixel < minp) minp = pixel; if (pixel > maxp) maxp = pixel; } -fprintf(stderr, " values = %g < %g\n", minp, maxp); +// fprintf(stderr, " values = %g < %g\n", minp, maxp); *pmax = maxp; /* copy value for the caller */ @@ -111,9 +111,11 @@ fprintf(stderr, ">>> %s ( %p %p )\n", __func__, src, dst); /* * trying some preprocessor filters */ -//foo = fimg_lissage_2x2(src); foo = fimg_lissage_3x3(src); -if (foo) fprintf(stderr, " lissage -> %d\n", foo); +if (foo) fprintf(stderr, " lissage 1 -> %d\n", foo); +foo = fimg_lissage_3x3(src); +if (foo) fprintf(stderr, " lissage 2 -> %d\n", foo); + foo = fimg_killborders(src); if (foo) fprintf(stderr, " killborder -> %d\n", foo); @@ -128,6 +130,7 @@ if (foo) { fprintf(stderr, "create tmp pic --> %d\n", foo); return foo; } + /* calcul de la pente : a vérifier ! */ for (y=0; y<(src->height-1); y++) { for (x=0; x<(src->width-1); x++) { @@ -147,11 +150,11 @@ for (y=0; y<(src->height-1); y++) { foo = calcul_histo_gray(&tmp, "histogramme.data", 499, &maxp); if (foo) fprintf(stderr, "<<< calcul histo -> %d\n", foo); - minp = 1e10; seuil = 0.700 * maxp; fprintf(stderr, " seuil = %f\n", seuil); +/* ésotérisme, quand tu nous tiens... */ for (offset=0; offset<(src->width*src->height); offset++) { pente = tmp.R[offset]; if (pente > seuil) { @@ -162,12 +165,17 @@ for (offset=0; offset<(src->width*src->height); offset++) { // fprintf(stderr, " minp = %f maxp = %f\n", minp, maxp); /* recopie dans l'image destination avec translation hauteur */ +fimg_clear(dst); for (offset=0; offset<(src->width*src->height); offset++) { pente = tmp.R[offset] - minp; - if (pente < 0.0) pente = 0.0; - dst->R[offset] = pente; - dst->G[offset] = pente; - dst->B[offset] = pente; + if (pente < 0.0) { + dst->R[offset] = -pente; + dst->G[offset] = -pente; + } + else { + dst->B[offset] = pente; + dst->G[offset] = pente; + } } foo = fimg_killborders(dst); diff --git a/experiment/movepixels.c b/experiment/movepixels.c index bc5e57f6..57471728 100644 --- a/experiment/movepixels.c +++ b/experiment/movepixels.c @@ -69,8 +69,7 @@ for (yd=0; ydheight; yd++) { if ( xs<0 || xs>psrc->width || ys<0 || ys>psrc->height ) { - rgb[0] = maxv; /* fucking bug XXX */ - rgb[1] = rgb[2] = 0.0; + rgb[0] = rgb[1] = rgb[2] = 0.0; outside++; } else { @@ -79,7 +78,6 @@ for (yd=0; ydheight; yd++) { } fimg_put_rgb(pdst, xd, yd, rgb); - } } @@ -89,7 +87,10 @@ for (yd=0; ydheight; yd++) { return 0; } /* ------------------------------------------------------------------- */ - +/* + * High level operateur, taking care of opening/closing + * files and doing memory management + */ int move_the_pixels(char *infile, char *statfile, char *outfile, int k) { int foo; @@ -145,9 +146,10 @@ srcfile = argv[1]; dstfile = argv[2]; verbosity = 0; -foo = move_the_pixels(srcfile, "cumul.fimg", dstfile, 3); +/* XXX the static picture file MUST be selectable by the yuser ! */ +foo = move_the_pixels(srcfile, "reference.fimg", dstfile, 3); -// fprintf(stderr, "move pixels %s -> %s = %d\n", srcfile, dstfile, foo); +fprintf(stderr, "move pixels %s -> %s = %d\n", srcfile, dstfile, foo); return 0; } diff --git a/experiment/remotegrab.c b/experiment/remotegrab.c new file mode 100644 index 00000000..e69de29b