forked from tTh/FloatImg
clamp me hardly, say the pixel
This commit is contained in:
parent
3b7b4f234c
commit
f451a8c8fe
12
floatimg.h
12
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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
|
Loading…
Reference in New Issue