From fe9a14e2b5194b595aea8515556ece593a5cb3ed Mon Sep 17 00:00:00 2001 From: tth Date: Wed, 18 May 2022 10:26:29 +0200 Subject: [PATCH] small tuning... --- Fonderie/sfx.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Fonderie/sfx.c b/Fonderie/sfx.c index 87957fa..00b601a 100644 --- a/Fonderie/sfx.c +++ b/Fonderie/sfx.c @@ -28,28 +28,32 @@ int graylevel2popcolors(FloatImg *src, FloatImg *dst, int k) { int x, y; float rgb[3]; -float theoric_maxval; +float theoric_maxval, real_maxv; #if DEBUG_LEVEL fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, k); #endif theoric_maxval = src->fval * src->count; -fprintf(stderr, "theoric maxval = %f\n", theoric_maxval); +real_maxv = fimg_get_maxvalue(src); +#if DEBUG_LEVEL +fprintf(stderr, "maxval: theoric= %.3f real= %.3f\n", \ + theoric_maxval, real_maxv); +#endif fimg_clear(dst); -// fimg_export_picture(src, "src.png", 0); for (y=0; yheight; y++) { for (x=0; xwidth; x++) { fimg_get_rgb(src, x, y, rgb); - rgb[1] = fabs(rgb[0] - rgb[2]); + rgb[0] = real_maxv * fabs(cos(21.0 * rgb[0] / real_maxv)); + rgb[1] = real_maxv * fabs(cos(31.0 * rgb[1] / real_maxv)); + rgb[2] = real_maxv * fabs(cos(11.0 * rgb[2] / real_maxv)); fimg_put_rgb(dst, x, y, rgb); } } -// fimg_export_picture(dst, "dst.png", 0); return 0; }