diff --git a/floatimg.h b/floatimg.h index afb0829d..a3e5d03a 100644 --- a/floatimg.h +++ b/floatimg.h @@ -79,6 +79,7 @@ int fimg_to_gray(FloatImg *head); void fimg_add_cste(FloatImg *fi, float value); void fimg_mul_cste(FloatImg *fi, float value); void fimg_drand48(FloatImg *fi, float kmul); +int fimg_count_negativ(FloatImg *fi); /* various funcs modules */ int fimg_load_from_png(char *filename, FloatImg *fimg); diff --git a/lib/fimg-math.c b/lib/fimg-math.c index d8513b04..873f3229 100644 --- a/lib/fimg-math.c +++ b/lib/fimg-math.c @@ -108,6 +108,27 @@ for (idx=0; idxtype != FIMG_TYPE_RGB) { + fprintf(stderr, "%s : type %d invalide\n", + __func__, fi->type); + return -1; + } + +nbre = fi->width * fi->height * fi->type; + +count = 0; +for (idx=0; idxR[idx] < 0.0) count++; + } + +return count; +} +/* ---------------------------------------------------------------- */ void fimg_mul_cste(FloatImg *fi, float value) { int nbre, idx; diff --git a/tools/fimgstats.c b/tools/fimgstats.c index d5306020..8642e46c 100644 --- a/tools/fimgstats.c +++ b/tools/fimgstats.c @@ -31,7 +31,12 @@ for (foo=0; foo<4; foo++) printf(" %c %14.6f\n", "RGBA"[foo], moyennes[foo]); fvalue = fimg_get_maxvalue(fimg); -printf("max value %f\n", fvalue); +printf("max value %f\n", fvalue); + +foo = fimg_count_negativ(fimg); +if (foo) { + fprintf(stderr, "%d negative values\n", foo); + } return 0; }