From 0651d8de7af506793601ca1b66120d582297536f Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 6 Aug 2020 13:13:10 +0200 Subject: [PATCH] a new function --- floatimg.h | 1 + funcs/saturation.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/floatimg.h b/floatimg.h index 3e62026b..9803f033 100644 --- a/floatimg.h +++ b/floatimg.h @@ -122,6 +122,7 @@ int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval); int fimg_mix_rgb_gray(FloatImg *img, float mix); +int fimg_shift_to_zero(FloatImg *s, FloatImg *d, float coefs[6]); /* module funcs/geometry.c */ diff --git a/funcs/saturation.c b/funcs/saturation.c index 68ff3882..e36ab08c 100644 --- a/funcs/saturation.c +++ b/funcs/saturation.c @@ -41,4 +41,26 @@ for (y=0; yheight; y++) { return 0; } +/* -------------------------------------------------------------- */ +int fimg_shift_to_zero(FloatImg *s, FloatImg *d, float coefs[6]) +{ +int sz, idx; + +sz = s->width * s->height; + +if (FIMG_TYPE_RGB != img->type) { + fprintf(stderr, "%s bad type\n", __func__); + return -6; + } + +for (idx=0; idxR[idx] = s->R[idx] - coefs[0]; + d->G[idx] = s->G[idx] - coefs[2]; + d->B[idx] = s->B[idx] - coefs[4]; + } + +return 0; +} + + /* -------------------------------------------------------------- */