Compare commits

...

2 Commits

Author SHA1 Message Date
2a2bc51e70 using autoshift to zero 2021-02-24 12:35:31 +01:00
8bbe639ad5 + auto shift to zero 2021-02-24 12:11:59 +01:00
3 changed files with 42 additions and 4 deletions

View File

@ -126,12 +126,22 @@ if (retval) {
fprintf(stderr, "%s error %d on filter\n", __func__, retval); fprintf(stderr, "%s error %d on filter\n", __func__, retval);
exit(1); exit(1);
} }
foo = fimg_auto_shift_to_zero(&img, &img);
if (foo) {
fprintf(stderr, "%s: err %d zero shift\n", __func__, foo);
exit(1);
}
/** may be, we can check for negative values ? */ /** may be, we can check for negative values ? */
/** or is this useless because whe have shifted to zero ? */
if (verbosity > 1) { if (verbosity > 1) {
foo = fimg_count_negativ(&img); foo = fimg_count_negativ(&img);
if (foo) {
fprintf(stderr, "%s -> %d / %d negative pixels\n", __func__, fprintf(stderr, "%s -> %d / %d negative pixels\n", __func__,
foo, img.width*img.height); foo, img.width*img.height);
} }
}
fimg_killborders(&img); fimg_killborders(&img);
fimg_copy_data(&img, pimg); fimg_copy_data(&img, pimg);

View File

@ -3,7 +3,7 @@
* ugly code from tTh * ugly code from tTh
*/ */
#define FIMG_VERSION 119 #define FIMG_VERSION 120
/* /*
* in memory descriptor * in memory descriptor
@ -128,7 +128,10 @@ int fimg_power_2(FloatImg *s, FloatImg *d, double maxval);
int fimg_cos_01(FloatImg *s, FloatImg *d, double maxval); int fimg_cos_01(FloatImg *s, FloatImg *d, double maxval);
int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval); int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval);
int fimg_mix_rgb_gray(FloatImg *img, float mix); int fimg_mix_rgb_gray(FloatImg *img, float mix);
/* funcs/saturation.c */
int fimg_shift_to_zero(FloatImg *s, FloatImg *d, float coefs[6]); int fimg_shift_to_zero(FloatImg *s, FloatImg *d, float coefs[6]);
int fimg_auto_shift_to_zero(FloatImg *s, FloatImg *d);
/* --> funcs/plasmas.c */ /* --> funcs/plasmas.c */
int fimg_prototype_plasma(FloatImg *img, double time, int type); int fimg_prototype_plasma(FloatImg *img, double time, int type);

View File

@ -70,5 +70,30 @@ for (idx=0; idx<sz; idx++) {
return 0; return 0;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
int fimg_auto_shift_to_zero(FloatImg *src, FloatImg *dst)
{
float coefs[6];
int foo;
if (FIMG_TYPE_RGB != src->type) {
fprintf(stderr, "%s: bad image type %d\n", __func__, src->type);
return -6;
}
foo = fimg_get_minmax_rgb(src, coefs);
if (foo) {
fprintf(stderr, "%s: err %d get minmax\n", __func__, foo);
return foo;
}
foo = fimg_shift_to_zero(src, dst, coefs);
if (foo) {
fprintf(stderr, "%s WTF?\n", __func__);
return foo;
}
return 0;
}
/* -------------------------------------------------------------- */