diff --git a/floatimg.h b/floatimg.h index 46a206fe..bee8dfc6 100644 --- a/floatimg.h +++ b/floatimg.h @@ -20,7 +20,7 @@ * https://git.tetalab.org/tTh/FloatImg */ -#define FIMG_VERSION (198) +#define FIMG_VERSION (201) #define RELEASE_NAME ("noname") /* XXX add a test for stdint.h / uint32_t XXX */ @@ -233,7 +233,7 @@ int fimg_qsort_rgb_b(FloatImg *psrc, FloatImg *pdst, int notused); /* module funcs/equalize.c */ int fimg_equalize_compute(FloatImg *src, void *vptr, float vmax); -int fimg_equalize(FloatImg *src, float vmax); +int fimg_equalize(FloatImg *src, double vmax); int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k); int fimg_desaturate(FloatImg *src, FloatImg *dst, int notused); @@ -285,6 +285,7 @@ int fimg_meanvalues(FloatImg *head, float means[4]); int fimg_to_gray(FloatImg *head); int fimg_add_cste(FloatImg *fi, float value); int fimg_mul_cste(FloatImg *fi, float value); +int fimg_div_cste(FloatImg *fi, float value); int fimg_ajust_from_grab(FloatImg *fi, double maxima, int notused); int fimg_absolute(FloatImg *fimg); void fimg_drand48(FloatImg *fi, float kmul); diff --git a/lib/fimg-math.c b/lib/fimg-math.c index 1e24d53d..17b7baa5 100644 --- a/lib/fimg-math.c +++ b/lib/fimg-math.c @@ -296,6 +296,33 @@ if (fi->type == FIMG_TYPE_GRAY) { return 0; } /* ---------------------------------------------------------------- */ +/* nouveau 17 septembre 2022 */ +int fimg_div_cste(FloatImg *fi, float value) +{ +int nbre, idx; + +if ( (fi->type != FIMG_TYPE_RGB) && (fi->type != FIMG_TYPE_GRAY) ) { + fprintf(stderr, "%s : type %d invalide\n", + __func__, fi->type); + return -44; + } + +nbre = fi->width * fi->height; +if (fi->type == FIMG_TYPE_RGB) { + for (idx=0; idxR[idx] /= value; + fi->G[idx] /= value; + fi->B[idx] /= value; + } + } +if (fi->type == FIMG_TYPE_GRAY) { + for (idx=0; idxR[idx] /= value; + } + } +return 0; +} +/* ---------------------------------------------------------------- */ /* * oh, please explain the usecase of this function ! */ diff --git a/tools/cumulfimgs.c b/tools/cumulfimgs.c index 26efa200..2fbac9ce 100644 --- a/tools/cumulfimgs.c +++ b/tools/cumulfimgs.c @@ -40,9 +40,10 @@ void help(int v) puts(""); puts("$ cumulfimgs a.fimg b.fimg c-fimg ..."); puts("cumulator options :"); -puts("\t-v\tincrease verbosity"); -puts("\t-o\tname of output file"); puts("\t-g\tconvert to gray level"); +puts("\t-o\tname of output file"); +puts("\t-s\trescale end image"); +puts("\t-v\tincrease verbosity"); puts(""); if (verbosity) { puts("Xperiment"); fimg_print_version(v); } exit(0); @@ -52,22 +53,25 @@ int main(int argc, char *argv[]) { int foo, idx; int opt; -int compte = 0; -int to_gray = 0; -int experiment = 0; -char *output_file = "out.fimg"; +int compte = 0; +int to_gray = 0; +int experiment = 0; +int rescale = 0; +int src_loaded = 0; + +char *output_file = "out.fimg"; FloatImg accu, temp; -int src_loaded = 0; float vals[6]; g_width = g_height = 0; -while ((opt = getopt(argc, argv, "gho:vx")) != -1) { +while ((opt = getopt(argc, argv, "gho:svx")) != -1) { switch(opt) { case 'g': to_gray = 1; break; case 'h': help(1); break; case 'o': output_file = optarg; break; + case 's': rescale = 1; break; case 'v': verbosity++; break; case 'x': experiment++; break; } @@ -84,7 +88,7 @@ for (idx=optind; idx %d\n", argv[idx],foo); + fprintf(stderr, "testfile %s -> %d\n", argv[idx], foo); exit(1); } @@ -104,11 +108,16 @@ for (idx=optind; idx