diff --git a/floatimg.h b/floatimg.h index c9e40d0..ebf8cea 100644 --- a/floatimg.h +++ b/floatimg.h @@ -2,7 +2,7 @@ * floatimg.h */ -#define FIMG_VERSION 94 +#define FIMG_VERSION 95 /* * in memory descriptor @@ -80,8 +80,17 @@ int fimg_minimum(FloatImg *a, FloatImg *b, FloatImg *d); int fimg_maximum(FloatImg *a, FloatImg *b, FloatImg *d); +/* funcs/filtrage.c */ + +typedef struct { + float matrix[9]; + float mult; + float offset; + } FimgFilter3x3; + int fimg_killborders(FloatImg *img); int fimg_lissage_2x2(FloatImg *img); +int fimg_filter_3x3(FloatImg *s, FloatImg *d, FimgFilter3x3 *filtr); /* 'sfx0' module */ int fimg_killcolors_a(FloatImg *fimg, float fval); @@ -127,6 +136,7 @@ void fimg_mul_cste(FloatImg *fi, float value); int fimg_normalize(FloatImg *fi, double maxima, int notused); void fimg_drand48(FloatImg *fi, float kmul); int fimg_count_negativ(FloatImg *fi); +int fimg_clamp_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 9fef44b..bfcd23e 100644 --- a/lib/fimg-math.c +++ b/lib/fimg-math.c @@ -144,6 +144,31 @@ for (idx=0; idxR[idx] < 0.0) count++; } +return count; +} +/* ---------------------------------------------------------------- */ +/* nouveau 29 fevrier 2020 */ +int fimg_clamp_negativ(FloatImg *fi) +{ +int nbre, idx; +int count; + +if (fi->type != 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) { + fi->R[idx] = 0.0; + count++; + } + } + return count; } /* ---------------------------------------------------------------- */