small tuning...

This commit is contained in:
tth 2022-05-18 10:26:29 +02:00
parent 11082c0d08
commit fe9a14e2b5

View File

@ -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; y<src->height; y++) {
for (x=0; x<src->width; 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;
}