diff --git a/Fonderie/fonctions.h b/Fonderie/fonctions.h index eb304f5..ff1fa93 100644 --- a/Fonderie/fonctions.h +++ b/Fonderie/fonctions.h @@ -40,6 +40,8 @@ int create_fifo(int nbslot, int w, int h, int t); * funcs in 'sfx.c' */ +int binarize(FloatImg *pimg, int notused); + int brotche_rand48_a(FloatImg *fimg, float ratio, float mval); int brotche_rand48_b(FloatImg *fimg, float ratio, float mval); int colors_brotcher(FloatImg *fimg, float fval); diff --git a/Fonderie/sfx.c b/Fonderie/sfx.c index e56841f..114de94 100644 --- a/Fonderie/sfx.c +++ b/Fonderie/sfx.c @@ -13,12 +13,43 @@ #include "fonctions.h" /* -------------------------------------------------------------- */ -/* global vars from main +/* here are global vars exported by the main module */ extern int verbosity; /* -------------------------------------------------------------- */ +int binarize(FloatImg *pimg, int notused) +{ +float mm[6], mR, mG, mB; +int foo, x, y; +float rgb[3]; +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, notused); +#endif + +foo = fimg_get_minmax_rgb(pimg, mm); +mR = (mm[1] - mm[0]) / 2.0; +mG = (mm[3] - mm[2]) / 2.0; +mB = (mm[5] - mm[4]) / 2.0; + +if (verbosity > 1) + fprintf(stderr, "%s: %f %f %f\n", __func__, mR, mG, mB); + +for (y=0; yheight; y++) { + for (x=0; xwidth; x++) { + fimg_get_rgb(pimg, x, y, rgb); + if (rgb[0] < mR) rgb[0] = mm[0]; + else rgb[0] = mm[1]; + if (rgb[1] < mG) rgb[1] = mm[2]; + else rgb[1] = mm[3]; + if (rgb[2] < mB) rgb[2] = mm[4]; + else rgb[2] = mm[5]; + } + } + +return 0; +} /* -------------------------------------------------------------- */ int brotche_rand48_a(FloatImg *fimg, float ratio, float mval) {