adding the COS01 contrast method

This commit is contained in:
2019-11-14 14:23:12 +01:00
parent e81055756e
commit 12197cc171
5 changed files with 64 additions and 11 deletions

View File

@@ -41,7 +41,7 @@ int nbre, idx;
double dval;
if (s->type != FIMG_TYPE_RGB) {
fprintf(stderr, "%s : type %d invalide\n",
fprintf(stderr, "%s : src type %d invalide\n",
__func__, s->type);
return -4;
}
@@ -49,6 +49,13 @@ if (s->type != FIMG_TYPE_RGB) {
if (NULL==d) {
d = s;
}
else {
if (d->type != FIMG_TYPE_RGB) {
fprintf(stderr, "%s : dst type %d invalide\n",
__func__, s->type);
return -4;
}
}
nbre = s->width * s->height * 3;
@@ -58,7 +65,42 @@ for (idx=0; idx<nbre; idx++) {
d->R[idx] = maxval * dval * dval;
}
return -1;
return 0;
}
/* ---------------------------------------------------------------- */
/*
#macro Cos_01( X )
(0.5-0.5*cos( 3.141592654 * X))
#end
*/
int fimg_cos_01(FloatImg *s, FloatImg *d, double maxval)
{
int nbre, idx;
double dval;
if (s->type != FIMG_TYPE_RGB) {
fprintf(stderr, "%s : type %d invalide\n",
__func__, s->type);
return -4;
}
if (NULL==d) {
d = s;
}
nbre = s->width * s->height * 3;
for (idx=0; idx<nbre; idx++) {
dval = s->R[idx] / maxval;
d->R[idx] = maxval * (0.5 - 0.5 * cos(3.141592654*dval));
}
return 0;
}
/* ---------------------------------------------------------------- */
/* ---------------------------------------------------------------- */