From 5d121dee874e28e3cd9c0c3da94d7fa3823d8f7c Mon Sep 17 00:00:00 2001 From: tth Date: Fri, 26 Mar 2021 05:40:45 +0100 Subject: [PATCH] moving trinarize func --- Fonderie/crapulator.c | 2 +- Fonderie/sfx.c | 46 +----------------------------------------- floatimg.h | 3 ++- funcs/sfx2.c | 47 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 47 deletions(-) diff --git a/Fonderie/crapulator.c b/Fonderie/crapulator.c index dfa6901d..26603f57 100644 --- a/Fonderie/crapulator.c +++ b/Fonderie/crapulator.c @@ -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); diff --git a/Fonderie/sfx.c b/Fonderie/sfx.c index 7b8c88ab..17c3060c 100644 --- a/Fonderie/sfx.c +++ b/Fonderie/sfx.c @@ -306,57 +306,13 @@ for (y=0; yheight; 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; fooR; - 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) diff --git a/floatimg.h b/floatimg.h index d5d5d42a..4d3c70f7 100644 --- a/floatimg.h +++ b/floatimg.h @@ -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, /* module sfx2.c */ int fimg_binarize(FloatImg *pimg, int notused); +int fimg_trinarize(FloatImg *pimg, int notused); /* funcs/rotate.c module */ /* #coronamaison */ diff --git a/funcs/sfx2.c b/funcs/sfx2.c index 12acbecb..b05e2aab 100644 --- a/funcs/sfx2.c +++ b/funcs/sfx2.c @@ -45,3 +45,50 @@ for (foo=0; foo>> %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; fooR; + 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; +} +/* -------------------------------------------------------------- */ +