From 951dc4450f159b8f449dec4e95b0cfb4a5d180c9 Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 3 Sep 2020 01:37:53 +0200 Subject: [PATCH] working on histogram computation --- funcs/Makefile | 5 ++++- funcs/equalize.c | 6 +++--- funcs/t.c | 35 ++++++++++++++++++++++++++++++++++- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/funcs/Makefile b/funcs/Makefile index edc0db89..67f3b62b 100644 --- a/funcs/Makefile +++ b/funcs/Makefile @@ -4,7 +4,7 @@ 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 geometry.o rotate.o \ - equalize.o fimg-fits.o saturation.o + equalize.o fimg-fits.o saturation.o histogram.o #--------------------------------------------------------------- @@ -45,6 +45,9 @@ rotate.o: rotate.c $(DEPS) saturation.o: saturation.c $(DEPS) gcc $(COPT) -c $< +histogram.o: histogram.c $(DEPS) + gcc $(COPT) -c $< + equalize.o: equalize.c $(DEPS) gcc $(COPT) -c $< diff --git a/funcs/equalize.c b/funcs/equalize.c index b0b15995..9c0465ec 100644 --- a/funcs/equalize.c +++ b/funcs/equalize.c @@ -34,9 +34,9 @@ dr = minmax[1] - minmax[0]; dg = minmax[3] - minmax[2]; db = minmax[5] - minmax[4]; -printf("Rmin %12.4g Rmax %12.4g delta %12.4g\n", minmax[0], minmax[1], dr); -printf("Gmin %12.4g Gmax %12.4g delta %12.4g\n", minmax[2], minmax[3], dg); -printf("Bmin %12.4g Bmax %12.4g delta %12.4g\n", minmax[4], minmax[5], db); +printf("Rmin %12.4g Rmax %12.4g delta %12.4g\n", minmax[0], minmax[1], dr); +printf("Gmin %12.4g Gmax %12.4g delta %12.4g\n", minmax[2], minmax[3], dg); +printf("Bmin %12.4g Bmax %12.4g delta %12.4g\n", minmax[4], minmax[5], db); if ( (minmax[0]<0.0) || (minmax[2]<0.0) || (minmax[4]<0.0) ) { fprintf(stderr, "%s: negative value ?\n", __func__); diff --git a/funcs/t.c b/funcs/t.c index ae5496de..cd024b0a 100644 --- a/funcs/t.c +++ b/funcs/t.c @@ -401,7 +401,36 @@ fprintf(stderr, "save as png -> %d\n", foo); return 0; } /* --------------------------------------------------------------------- */ -enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff }; + + /* func in histogram.c */ +int fimg_essai_histo(FloatImg *src, char *outpic, int k); + + +int essai_histogramme(char *fname, int k) +{ +FloatImg fimg; +int foo; +fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, k); + +foo = fimg_create_from_dump(fname, &fimg); +if (foo) { + fprintf(stderr, "%s: err load '%s'\n", __func__, fname); + return foo; + } + +foo = fimg_essai_histo(&fimg, "out.png", k); +if (foo) { + fprintf(stderr, "essai_histo -> %d\n", foo); + return foo; + } + +fprintf(stderr, "\\o/ end of %s\n", __func__); + +return -1; +} +/* --------------------------------------------------------------------- */ +enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff, + Histo }; typedef struct { char *name; int Cmd; @@ -416,6 +445,7 @@ Command commands[] = { { "wfits", Wfits }, { "wpng", Wpng }, { "wtiff", Wtiff }, + { "histo", Histo }, { NULL, 0 } } ; @@ -506,6 +536,9 @@ switch(opt) { case Wtiff: foo = essai_ecriture_tiff(filename); break; + case Histo: + foo = essai_histogramme(filename, 0); + break; default: fprintf(stderr, "%s : bad command\n", command); exit(1);