forked from tTh/FloatImg
added binarize function
This commit is contained in:
parent
3cb969866f
commit
5b0670006a
@ -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);
|
||||
|
@ -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; y<pimg->height; y++) {
|
||||
for (x=0; x<pimg->width; 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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user