From 57ef940536f0de5bf02cbf5a2434db53d06a08d2 Mon Sep 17 00:00:00 2001 From: tonton Th Date: Wed, 22 Jan 2020 18:16:26 +0100 Subject: [PATCH] a new function : fimg_desaturate --- floatimg.h | 4 ++-- lib/fimg-2gray.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/floatimg.h b/floatimg.h index d4b91e4..272c059 100644 --- a/floatimg.h +++ b/floatimg.h @@ -2,7 +2,7 @@ * floatimg.h */ -#define FIMG_VERSION 87 +#define FIMG_VERSION 88 /* * in memory descriptor @@ -57,7 +57,6 @@ int fimg_print_version(int k); void fimg_printhead(FloatImg *h); int fimg_describe(FloatImg *head, char *txt); char *fimg_str_type(int type); -int fimg_fileinfo(char *fname, int *datas); int fimg_plot_rgb (FloatImg *head, int x, int y, float r, float g, float b); int fimg_clear(FloatImg *fimg); int fimg_add_rgb(FloatImg *head, int x, int y, float r, float g, float b); @@ -91,6 +90,7 @@ int fimg_cos_01(FloatImg *s, FloatImg *d, double maxval); int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval); int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k); +int fimg_desaturate(FloatImg *src, FloatImg *dst, int k); /* module funcs/rampes.c */ int fimg_hdeg_a(FloatImg *img, double dcoef); diff --git a/lib/fimg-2gray.c b/lib/fimg-2gray.c index 70723bb..52a774d 100644 --- a/lib/fimg-2gray.c +++ b/lib/fimg-2gray.c @@ -52,6 +52,28 @@ for (foo=0; footype || FIMG_TYPE_RGB != dst->type) { + fprintf(stderr, "%s : bad image type\n", __func__, src->type, src); + return -18; + } + +/* entering the main processing loop */ +nbb = src->width * src->height; + +for (foo=0; fooR[foo] = dst->G[foo] = dst->B[foo] = + (src->R[foo] + src->G[foo] + src->B[foo]) / 3.0; + } + +return -99; +} +/* --------------------------------------------------------------------- */