clamp me hardly, say the pixel

This commit is contained in:
Tonton Th 2020-02-29 20:01:11 +01:00
parent 3b7b4f234c
commit f451a8c8fe
2 changed files with 36 additions and 1 deletions

View File

@ -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);

View File

@ -144,6 +144,31 @@ for (idx=0; idx<nbre; idx++) {
if (fi->R[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; idx<nbre; idx++) {
if (fi->R[idx] < 0.0) {
fi->R[idx] = 0.0;
count++;
}
}
return count;
}
/* ---------------------------------------------------------------- */