added normalize function, need more tests

This commit is contained in:
2020-01-07 13:46:09 +01:00
parent 6d13293ef2
commit cef00ac04e
3 changed files with 68 additions and 8 deletions

View File

@@ -158,14 +158,43 @@ if (fi->type != FIMG_TYPE_RGB) {
}
nbre = fi->width * fi->height * fi->type;
// #if DEBUG_LEVEL
fprintf(stderr, "%s, nbre is %d\n", __func__, nbre);
// #endif
#if DEBUG_LEVEL
fprintf(stderr, "%s, nbre of datum is %d\n", __func__, nbre);
#endif
for (idx=0; idx<nbre; idx++) {
fi->R[idx] *= value;
}
}
/* ---------------------------------------------------------------- */
int fimg_normalize(FloatImg *fi, double maxima, int notused)
{
double coef;
if (fi->type != FIMG_TYPE_RGB) {
fprintf(stderr, "%s : type %d invalide\n",
__func__, fi->type);
return -99;
}
if (fi->count < 1) {
fprintf(stderr, "%s : count %d is invalid\n", __func__, fi->count);
return -98;
}
coef = 1.0 / ((double)fi->count * (double)fi->fval);
if (verbosity) {
fprintf(stderr, "image @ %p\n", fi);
fprintf(stderr, "fval %f\n", fi->fval);
fprintf(stderr, "count %d\n", fi->count);
fprintf(stderr, "coef %f\n", coef);
}
fimg_mul_cste(fi, coef);
return 0;
}
/* ---------------------------------------------------------------- */
/* Warning: this function is _very_ slow */
void fimg_drand48(FloatImg *fi, float kmul)
{