diff --git a/Fonderie/crapulator.c b/Fonderie/crapulator.c index 423c760..2ac41bb 100644 --- a/Fonderie/crapulator.c +++ b/Fonderie/crapulator.c @@ -123,7 +123,7 @@ switch (idFx) { retval = trinarize(image, 0); break; case 24: /* experiment ! */ - retval = des_bords_sombres_a(image, 260); + retval = des_bords_sombres_a(image, 160); break; case 25: /* please make this function more tweakable */ diff --git a/Fonderie/sfx.c b/Fonderie/sfx.c index c603d29..90e8a7c 100644 --- a/Fonderie/sfx.c +++ b/Fonderie/sfx.c @@ -23,27 +23,29 @@ extern int verbosity; int des_bords_sombres_a(FloatImg *pimg, int offset) { float coef; -int xpos, lidx, y; +int xpos, xp2, lidx, y; #if DEBUG_LEVEL fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, offset); #endif -if (offset<0 || offset>pimg->width) { +if (offset<0 || offset>=pimg->width) { fprintf(stderr, "%s offset %d is bad\n", __func__, offset); return -66; } for (y=0; yheight; y++) { - lidx = y * pimg->width; + lidx = y * pimg->width; /* start of the + 'y' line */ for (xpos=0; xposR[xpos+lidx] *= coef; pimg->G[xpos+lidx] *= coef; pimg->B[xpos+lidx] *= coef; - pimg->R[(pimg->width-xpos)+lidx] *= coef; - pimg->G[(pimg->width-xpos)+lidx] *= coef; - pimg->B[(pimg->width-xpos)+lidx] *= coef; + xp2 = pimg->width-xpos; + pimg->R[xp2+lidx] *= coef; + pimg->G[xp2+lidx] *= coef; + pimg->B[xp2+lidx] *= coef; } } @@ -52,6 +54,28 @@ return 0; /* -------------------------------------------------------------- */ int trinarize(FloatImg *pimg, int notused) { +float mm[6], mRa, mGa, mBa, mRb, mGb, mBb; +int foo, size; + +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, notused); +#endif + +foo = fimg_get_minmax_rgb(pimg, mm); +mRa = (mm[1] - mm[0]) * 0.33333; +mGa = (mm[3] - mm[2]) * 0.33333; +mBa = (mm[5] - mm[4]) * 0.33333; +mRb = (mm[1] - mm[0]) * 0.66666; +mGb = (mm[3] - mm[2]) * 0.66666; +mBb = (mm[5] - mm[4]) * 0.66666; + +size = pimg->width * pimg->height; + +for (foo=0; foo