Browse Source

moving trinarize func

master
tth 2 years ago
parent
commit
5d121dee87
  1. 2
      Fonderie/crapulator.c
  2. 46
      Fonderie/sfx.c
  3. 3
      floatimg.h
  4. 47
      funcs/sfx2.c

2
Fonderie/crapulator.c

@ -220,7 +220,7 @@ switch (idFx) { @@ -220,7 +220,7 @@ switch (idFx) {
retval = fimg_binarize(image, 0);
break;
case CR_trinarize:
retval = trinarize(image, 0);
retval = fimg_trinarize(image, 0);
break;
case CR_liss2x2:
retval = fimg_lissage_2x2(image);

46
Fonderie/sfx.c

@ -306,57 +306,13 @@ for (y=0; y<pimg->height; y++) { @@ -306,57 +306,13 @@ for (y=0; y<pimg->height; y++) {
}
}
return 0;
}
/* -------------------------------------------------------------- */
int trinarize(FloatImg *pimg, int notused)
{
float mm[6], mRa, mGa, mBa, mRb, mGb, mBb;
float *fptr;
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<size; foo++) {
fptr = pimg->R;
if (fptr[foo] < mRa || fptr[foo] > mRb)
fptr[foo] = mm[0];
else
fptr[foo] = mm[1];
fptr = pimg->G;
if (fptr[foo] < mGa || fptr[foo] > mGb)
fptr[foo] = mm[2];
else
fptr[foo] = mm[3];
fptr = pimg->B;
if (fptr[foo] < mBa || fptr[foo] > mBb)
fptr[foo] = mm[4];
else
fptr[foo] = mm[5];
}
return 0;
}
/* -------------------------------------------------------------- */
/*
* int binarize(FloatImg *pimg, int notused) was now in
* funcs/sfx2.c
* same move for trinarize.
*/
/* -------------------------------------------------------------- */
int brotche_rand48_a(FloatImg *fimg, float ratio, float mval)

3
floatimg.h

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
* http://la.buvette.org/photos/cumul
*/
#define FIMG_VERSION 126
#define FIMG_VERSION 127
/*
* in memory descriptor
@ -114,6 +114,7 @@ int fimg_highlight_color(FloatImg *src, FloatImg *dst, @@ -114,6 +114,7 @@ int fimg_highlight_color(FloatImg *src, FloatImg *dst,
/* module sfx2.c */
int fimg_binarize(FloatImg *pimg, int notused);
int fimg_trinarize(FloatImg *pimg, int notused);
/* funcs/rotate.c module */
/* #coronamaison */

47
funcs/sfx2.c

@ -45,3 +45,50 @@ for (foo=0; foo<size; foo++) { @@ -45,3 +45,50 @@ for (foo=0; foo<size; foo++) {
return 0;
}
/* -------------------------------------------------------------- */
int fimg_trinarize(FloatImg *pimg, int notused)
{
float mm[6], mRa, mGa, mBa, mRb, mGb, mBb;
float *fptr;
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<size; foo++) {
fptr = pimg->R;
if (fptr[foo] < mRa || fptr[foo] > mRb)
fptr[foo] = mm[0];
else
fptr[foo] = mm[1];
fptr = pimg->G;
if (fptr[foo] < mGa || fptr[foo] > mGb)
fptr[foo] = mm[2];
else
fptr[foo] = mm[3];
fptr = pimg->B;
if (fptr[foo] < mBa || fptr[foo] > mBb)
fptr[foo] = mm[4];
else
fptr[foo] = mm[5];
}
return 0;
}
/* -------------------------------------------------------------- */

Loading…
Cancel
Save