forked from tTh/FloatImg
a new function : fimg_desaturate
This commit is contained in:
parent
1b2355f046
commit
57ef940536
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue