/* * SPECIAL EFFECTS * * Du code bien cracra / tTh / Tetalab */ #include #include #include #include #include #include "fonctions.h" /* -------------------------------------------------------------- */ /* 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]; fimg_put_rgb(pimg, x, y, rgb); } } return 0; } /* -------------------------------------------------------------- */ int brotche_rand48_a(FloatImg *fimg, float ratio, float mval) { int nbpix, todo, foo; int x, y; float fval; nbpix = fimg->width * fimg->height; todo = (int)((float)nbpix * ratio); if (verbosity > 1) { fprintf(stderr, "%s: ratio %f nbpix %d todo %d\n", __func__, ratio, nbpix, todo); } for (foo=0; foowidth; y = rand() % fimg->height; fimg_plot_rgb(fimg, x, y, fval, fval, fval); } return 0; } /* -------------------------------------------------------------- */ int brotche_rand48_b(FloatImg *fimg, float ratio, float mval) { int nbpix, todo, foo; int x, y; float fval; nbpix = fimg->width * fimg->height; todo = (int)((float)nbpix * ratio); if (verbosity > 1) { fprintf(stderr, "%s: ratio %f nbpix %d todo %d\n", __func__, ratio, nbpix, todo); } for (foo=0; foowidth-2)); y = rand() % fimg->height; fimg_plot_rgb(fimg, x-1, y, fval, 0.0, 0.0); fimg_plot_rgb(fimg, x , y, 0.0, 0.0, fval); fimg_plot_rgb(fimg, x+1, y, 0.0, fval, 0.0); } return 0; } /* -------------------------------------------------------------- */