2020-04-11 23:18:33 +02:00
|
|
|
/*
|
|
|
|
* FLOATIMG
|
2020-08-13 07:25:55 +02:00
|
|
|
* egalisation dynamique approximative
|
2020-04-11 23:18:33 +02:00
|
|
|
* #coronamaison Thu 09 Apr 2020 03:37:10 PM CEST
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "../floatimg.h"
|
|
|
|
|
|
|
|
extern int verbosity;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
2020-08-13 07:25:55 +02:00
|
|
|
int fimg_equalize_compute(FloatImg *src, void *vptr, float vmax)
|
2020-04-11 23:18:33 +02:00
|
|
|
{
|
|
|
|
float minmax[6];
|
|
|
|
int foo;
|
2020-08-13 07:25:55 +02:00
|
|
|
float dr, dg, db;
|
2020-04-11 23:18:33 +02:00
|
|
|
|
|
|
|
#if DEBUG_LEVEL
|
|
|
|
fprintf(stderr, ">>> %s ( %p )\n", __func__, src);
|
|
|
|
#endif
|
|
|
|
|
2020-08-13 07:25:55 +02:00
|
|
|
memset(minmax, 0, 6*sizeof(float));
|
|
|
|
|
2020-04-11 23:18:33 +02:00
|
|
|
foo = fimg_get_minmax_rgb(src, minmax);
|
2020-08-13 07:25:55 +02:00
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "err %d get minmax in %s\n", foo, __func__);
|
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
|
|
|
dr = minmax[1] - minmax[0];
|
|
|
|
dg = minmax[3] - minmax[2];
|
|
|
|
db = minmax[5] - minmax[4];
|
|
|
|
|
2020-09-03 01:37:53 +02:00
|
|
|
printf("Rmin %12.4g Rmax %12.4g delta %12.4g\n", minmax[0], minmax[1], dr);
|
|
|
|
printf("Gmin %12.4g Gmax %12.4g delta %12.4g\n", minmax[2], minmax[3], dg);
|
|
|
|
printf("Bmin %12.4g Bmax %12.4g delta %12.4g\n", minmax[4], minmax[5], db);
|
2020-04-11 23:18:33 +02:00
|
|
|
|
|
|
|
if ( (minmax[0]<0.0) || (minmax[2]<0.0) || (minmax[4]<0.0) ) {
|
|
|
|
fprintf(stderr, "%s: negative value ?\n", __func__);
|
|
|
|
return -4;
|
|
|
|
}
|
|
|
|
|
2020-08-13 07:25:55 +02:00
|
|
|
// printf("deltas %12.4g %12.4g %12.4g\n", dr, dg, db);
|
|
|
|
|
2020-04-11 23:18:33 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|