is trinarize ready ?

This commit is contained in:
tonton th 2020-12-01 13:10:27 +01:00
parent e17232f29c
commit 11c457aa81
3 changed files with 39 additions and 10 deletions

View File

@ -13,8 +13,8 @@ all: fonderie interpolator t
# ---------------------------------------------------------
t: t.c Makefile glitches.o
gcc ${COPT} $< glitches.o ${LIBS} -lz -o $@
t: t.c Makefile glitches.o sfx.o
gcc ${COPT} $< glitches.o sfx.o ${LIBS} -lz -o $@
# ---------------------------------------------------------

View File

@ -55,6 +55,7 @@ return 0;
int trinarize(FloatImg *pimg, int notused)
{
float mm[6], mRa, mGa, mBa, mRb, mGb, mBb;
float val, *fptr;
int foo, size;
#if DEBUG_LEVEL
@ -71,15 +72,30 @@ mBb = (mm[5] - mm[4]) * 0.66666;
size = pimg->width * pimg->height;
#define VAL (255.0)
for (foo=0; foo<size; foo++) {
; // XXX
fptr = pimg->R;
if (fptr[foo] < mRa || fptr[foo] > mRb)
fptr[foo] = 0.0;
else
fptr[foo] = VAL;
fptr = pimg->G;
if (fptr[foo] < mGa || fptr[foo] > mGb)
fptr[foo] = 0.0;
else
fptr[foo] = VAL;
fptr = pimg->B;
if (fptr[foo] < mBa || fptr[foo] > mBb)
fptr[foo] = 0.0;
else
fptr[foo] = VAL;
}
fprintf(stderr, "the function '%s' is not implemented\n", __func__);
exit(2);
return -1;
}
/* -------------------------------------------------------------- */

View File

@ -19,6 +19,9 @@ int verbosity;
#define LMAX 233.333
#define TIMER 1
int trinarize(FloatImg *pimg, int notused); // in sfx.c
int main(int argc, char *argv[])
{
int foo, iter, xloc, bloub;
@ -42,11 +45,11 @@ fimg_printhead(&image);
srand(getpid());
debut = fimg_timer_set(TIMER);
for (iter=0; iter<127; iter++) {
for (iter=0; iter<16; iter++) {
fimg_vdeg_a(&image, LMAX);
for (bloub=0; bloub<7; bloub++) {
for (bloub=0; bloub<16; bloub++) {
xloc = rand() % W;
omega = (float)(0.1 + drand48()*0.6) * 0.4;
foo = vertical_singlitch(&image, xloc, LMAX,
@ -54,12 +57,22 @@ for (iter=0; iter<127; iter++) {
if (foo) abort();
}
sprintf(buff, "/tmp/out%03d.png", iter);
sprintf(buff, "/tmp/out_a%03d.png", iter);
foo = fimg_save_as_png(&image, buff, 0);
if (foo) {
fprintf(stderr, "err %d saving to '%s'\n", foo, PNG);
fprintf(stderr, "err %d saving to '%s'\n", foo, buff);
exit(1);
}
foo = trinarize(&image, 0); /* XXX */
sprintf(buff, "/tmp/out_b%03d.png", iter);
foo = fimg_save_as_png(&image, buff, 0);
if (foo) {
fprintf(stderr, "err %d saving to '%s'\n", foo, buff);
exit(1);
}
}
fin = fimg_timer_set(TIMER);