a new function : fimg_desaturate

This commit is contained in:
tonton Th
2020-01-22 18:16:26 +01:00
parent 1b2355f046
commit 57ef940536
2 changed files with 24 additions and 2 deletions

View File

@@ -52,6 +52,28 @@ for (foo=0; foo<nbb; foo++) {
return 0;
}
/* --------------------------------------------------------------------- */
int fimg_desaturate(FloatImg *src, FloatImg *dst, int k)
{
int foo, nbb;
float fval;
/* we must check the validity of our parameters */
if (FIMG_TYPE_RGB != src->type || 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; foo<nbb; foo++) {
dst->R[foo] = dst->G[foo] = dst->B[foo] =
(src->R[foo] + src->G[foo] + src->B[foo]) / 3.0;
}
return -99;
}
/* --------------------------------------------------------------------- */