birthday new func: fimg_equalize

This commit is contained in:
tTh 2022-09-14 12:01:33 +02:00
parent 1b598227c3
commit e6379f6338
2 changed files with 46 additions and 2 deletions

View File

@ -20,8 +20,11 @@
* https://git.tetalab.org/tTh/FloatImg * https://git.tetalab.org/tTh/FloatImg
*/ */
#define FIMG_VERSION (197) #define FIMG_VERSION (198)
#define RELEASE_NAME ("noname") #define RELEASE_NAME ("noname")
/* XXX add a test for stdint.h / uint32_t XXX */
/* /*
* in memory descriptor of a floating image * in memory descriptor of a floating image
*/ */
@ -228,8 +231,9 @@ int fimg_classif_trial(FloatImg *src, FloatImg*dst, float fval, int notused);
int fimg_qsort_rgb_a(FloatImg *psrc, FloatImg *pdst, int notused); int fimg_qsort_rgb_a(FloatImg *psrc, FloatImg *pdst, int notused);
int fimg_qsort_rgb_b(FloatImg *psrc, FloatImg *pdst, int notused); int fimg_qsort_rgb_b(FloatImg *psrc, FloatImg *pdst, int notused);
/* module funcs/??????.c */ /* module funcs/equalize.c */
int fimg_equalize_compute(FloatImg *src, void *vptr, float vmax); int fimg_equalize_compute(FloatImg *src, void *vptr, float vmax);
int fimg_equalize(FloatImg *src, float vmax);
int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k); int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k);
int fimg_desaturate(FloatImg *src, FloatImg *dst, int notused); int fimg_desaturate(FloatImg *src, FloatImg *dst, int notused);

View File

@ -14,6 +14,46 @@
extern int verbosity; extern int verbosity;
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/* new func: Wed 14 Sep 2022 11:28:04 AM CEST
*/
int fimg_equalize(FloatImg *src, float vmax)
{
float mm[6], maxi, coef;
int foo;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %f )\n", __func__, src, vmax);
#endif
memset(mm, 0, 6*sizeof(float));
foo = fimg_get_minmax_rgb(src, mm);
if (foo) {
fprintf(stderr, "%s: err %d get_minmax\n", __func__, foo);
return foo;
}
maxi = mm[1] > mm[3] ? mm[1] : mm[3];
maxi = maxi > mm[5] ? maxi : mm[5];
coef = vmax / maxi;
if (verbosity) {
fprintf(stderr, "maximums %.3f %.3f %.3f %.3f\n",
mm[1], mm[3], mm[5], maxi);
fprintf(stderr, "vmax %f maxi %f multcoef = %g\n", vmax, maxi, coef);
}
foo = fimg_mul_cste(src, coef);
if (foo) {
fprintf(stderr, "%s: err %d mul_cste\n", __func__, foo);
return foo;
}
return 0;
}
/* --------------------------------------------------------------------- */
/*
*
* - wtf is this "void *vptr" thing ?
*/
int fimg_equalize_compute(FloatImg *src, void *vptr, float vmax) int fimg_equalize_compute(FloatImg *src, void *vptr, float vmax)
{ {
float minmax[6]; float minmax[6];