Compare commits

..

No commits in common. "423ab7f0eca3e74777b24f795fadf075c0066138" and "d50f2145ba5a08ad57a63afcf5245678e5579ee4" have entirely different histories.

7 changed files with 170 additions and 170 deletions

View File

@ -1,22 +0,0 @@
# Fonderie
Avec toutes ces fonctions disponibles et `grabvidseq`, nous
savons faire des images **floues***. L'étape suivante, les plus
pervers d'entre vous le savent déja, est celle de la création
de **films flous**.
## fonderie
Le programme principal, utilisé à partir de la ligne de commande
avec une foule d'options aux mnémoniques abscons.
Rassurez-vous, en général ils sont wrappables dans des scripts
shell. Il est même possible un jour qu'ils puissent lire des
paramètres dans `$(env)`.
## crapulator
C'est dans ce module qu'est codé le moteur de filtrage, utilisé
aussi bien en entrée qu'en sortie.

View File

@ -7,115 +7,35 @@
#include <floatimg.h> #include <floatimg.h>
#include "fonctions.h"
#include "crapulator.h" #include "crapulator.h"
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
int crapulator(FloatImg *image, int idFx, float fval) int crapulator(FloatImg *image, int notused)
{ {
int retval, foo; int retval;
FloatImg imgtmp; FloatImg imgtmp;
static int count = 0;
int flag_debug = 0;
float value;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d %f )\n", __func__, fprintf(stderr, ">>> %s ( %p %d )\n", __func__, image, notused);
image, idFx, fval);
#endif #endif
if (666==count) { /* contour 2x2 don't work inplace */
flag_debug = 1; fimg_clone(image, &imgtmp, 0);
fprintf(stderr, "DEBUG PT 1 in %s:%d\n", __func__, __LINE__);
fimg_save_as_png(image, "source.png", 0); /* so we work on a copy */
retval = fimg_contour_2x2(image, &imgtmp, 0);
if (retval) {
fprintf(stderr, "%s : err contour %d\n",
__func__, retval);
exit(1);
} }
switch (idFx) { /* and put back porcessed pixels */
case 0: /* DO NOTHING */ fimg_copy_data(&imgtmp, image);
retval = 0; break; fimg_destroy(&imgtmp);
case 1: return 0;
fimg_cos_01(image, image,
fimg_get_maxvalue(image));
break;
case 2:
fimg_cos_010(image, image,
fimg_get_maxvalue(image));
break;
case 3:
value = fimg_get_maxvalue(image);
fimg_mul_cste(image, -1.0);
fimg_add_cste(image, value);
foo = fimg_count_negativ(image);
if (foo) {
fimg_dump_to_file(image, "err.fimg", 0);
fprintf(stderr, "%s negativ %d\n",
__func__, foo);
return -78;
}
break;
case 4:
brotche_rand48_a(image, 0.20,
fimg_get_maxvalue(image));
break;
case 5:
brotche_rand48_b(image, 0.10,
fimg_get_maxvalue(image)*0.8);
break;
case 6:
fimg_killcolors_a(image, 0.0);
break;
case 7:
retval = fimg_colors_mixer_a(image, 2.0);
break;
case 8:
fimg_clone(image, &imgtmp, 0);
fimg_clear(&imgtmp);
if (flag_debug) {
fprintf(stderr, "DEBUG A contour 2x2\n");
fimg_save_as_png(image, "before.png", 0);
fimg_dump_to_file(image, "before.fimg", 0);
}
retval = fimg_contour_2x2(image, &imgtmp, 0);
if (retval) {
fprintf(stderr, "%s : err contour %d\n",
__func__, retval);
exit(1);
}
if (flag_debug) {
fprintf(stderr, "DEBUG B contour 2x2\n");
// fimg_save_as_png(&imgtmp, "contour.png", 0);
fimg_dump_to_file(&imgtmp, "contour.fimg", 0);
}
fimg_copy_data(&imgtmp, image);
fimg_destroy(&imgtmp);
break;
case 9:
retval = fimg_classif_trial(image, image, 0.37, 0);
if (retval) {
fprintf(stderr, "err %d in classif\n", retval);
exit(1);
}
break;
default :
fprintf(stderr, "%s : effect #%d invalid\n",
__func__, idFx);
return -77;
}
if (flag_debug) {
fprintf(stderr, "DEBUG PT 2 in %s:%d\n", __func__, __LINE__);
fimg_save_as_png(image, "after.png", 0);
}
count++; flag_debug = 0;
return retval;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */

View File

@ -2,5 +2,5 @@
* crapulator.h * crapulator.h
*/ */
int crapulator(FloatImg *image, int id_effect, float fparam); int crapulator(FloatImg *image, int notused);

View File

@ -11,7 +11,6 @@
#include <floatimg.h> #include <floatimg.h>
#include "fonctions.h" #include "fonctions.h"
#include "crapulator.h"
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
/* global vars from main /* global vars from main
@ -47,6 +46,104 @@ for (idx=0; idx<pfifo->nbslots; idx += step) {
return 0; return 0;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
int post_process_picture(FloatImg *image, int numFx, float fval)
{
int retval = 0;
int foo;
float value;
FloatImg imgtmp;
static int count, flag_debug;
if (666==count) {
flag_debug = 1;
fprintf(stderr, "DEBUG POINT 1 in %s\n", __func__);
fimg_save_as_png(image, "source.png", 0);
}
switch (numFx) {
case 0: /* DO NOTHING */ break;
case 1:
fimg_cos_01(image, image,
fimg_get_maxvalue(image));
break;
case 2:
fimg_cos_010(image, image,
fimg_get_maxvalue(image));
break;
case 3:
value = fimg_get_maxvalue(image);
fimg_mul_cste(image, -1.0);
fimg_add_cste(image, value);
foo = fimg_count_negativ(image);
if (foo) {
fimg_dump_to_file(image, "err.fimg", 0);
fprintf(stderr, "%s negativ %d\n", __func__, foo);
return -78;
}
break;
case 4:
brotche_rand48(image, 0.20,
fimg_get_maxvalue(image));
break;
case 5:
brotche_rand48_b(image, 0.10,
fimg_get_maxvalue(image)*0.8);
break;
case 6:
kill_colors_a(image, 0.0);
break;
case 7:
retval = fimg_colors_mixer_a(image, 2.0);
break;
case 8:
fimg_clone(image, &imgtmp, 0);
fimg_clear(&imgtmp);
if (flag_debug) {
fprintf(stderr, "DEBUG A contour 2x2\n");
fimg_save_as_png(image, "before.png", 0);
fimg_dump_to_file(image, "before.fimg", 0);
}
retval = fimg_contour_2x2(image, &imgtmp, 0);
if (retval) {
fprintf(stderr, "%s : err contour %d\n",
__func__, retval);
exit(1);
}
if (flag_debug) {
fprintf(stderr, "DEBUG B contour 2x2\n");
// fimg_save_as_png(&imgtmp, "contour.png", 0);
fimg_dump_to_file(&imgtmp, "contour.fimg", 0);
}
fimg_copy_data(&imgtmp, image);
fimg_destroy(&imgtmp);
break;
case 9:
retval = fimg_classif_trial(image, image, 0.42, 0);
if (retval) {
fprintf(stderr, "err %d in classif\n", retval);
exit(1);
}
break;
default :
fprintf(stderr, "%s : postproc #%d invalid\n",
__func__, numFx);
return -77;
}
if (flag_debug) {
fprintf(stderr, "DEBUG POINT 2 in %s\n", __func__);
fimg_save_as_png(image, "after.png", 0);
}
count++; flag_debug = 0;
return retval;
}
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
/* /*
* this func save the fifo content as * this func save the fifo content as
@ -68,10 +165,9 @@ if (convert_to_gray) {
// fprintf(stderr, "%p gray-washed\n", &fifo.total); // fprintf(stderr, "%p gray-washed\n", &fifo.total);
} }
foo = crapulator(&g_fifo.total, postproc, 0.0); foo = post_process_picture(&g_fifo.total, postproc, 0.0);
if (foo) { if (foo) {
fprintf(stderr, "%s: ERR post process picture -> %d\n", fprintf(stderr, "ERR post process picture -> %d\n", foo);
__func__, foo);
return foo; return foo;
} }

View File

@ -40,8 +40,9 @@ int create_fifo(int nbslot, int w, int h, int t);
* funcs in 'sfx.c' * funcs in 'sfx.c'
*/ */
int brotche_rand48_a(FloatImg *fimg, float ratio, float mval); int brotche_rand48(FloatImg *fimg, float ratio, float mval);
int brotche_rand48_b(FloatImg *fimg, float ratio, float mval); int brotche_rand48_b(FloatImg *fimg, float ratio, float mval);
int kill_colors_a(FloatImg *fimg, float fval);
int colors_brotcher(FloatImg *fimg, float fval); int colors_brotcher(FloatImg *fimg, float fval);
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */

View File

@ -12,7 +12,9 @@
#include "fonctions.h" #include "fonctions.h"
#include "crapulator.h" #include "crapulator.h"
int verbosity; int verbosity;
int convert_to_gray; int convert_to_gray;
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
@ -25,20 +27,17 @@ char ligne[200];
/* here, we put the picz in the fifo machinery */ /* here, we put the picz in the fifo machinery */
foo = insert_picture(image); foo = insert_picture(image);
if (foo) { if (foo) {
fprintf(stderr, "%s: err %d on insert\n", __func__, foo); fprintf(stderr, "%s : err %d on insert\n", __func__, foo);
return foo; return foo;
} }
sprintf(ligne, "p8/%05d.png", numero); sprintf(ligne, "p8/%05d.png", numero);
/* ^^^
XXX hardcoded value ? wtf ?
*/
foo = export_fifo(ligne, proc, step); foo = export_fifo(ligne, proc, step);
if (foo) { if (foo) {
fprintf(stderr, "%s: err %d on export\n", __func__, foo); fprintf(stderr, "%s : err %d on export\n", __func__, foo);
return foo; return foo;
} }
numero++; /* VERY IMPORTANT :) */ numero++; /* VERY IMPORTANT :) */
return 0; return 0;
@ -68,10 +67,10 @@ puts("");
return 0; return 0;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
#define BLANK 40 #define BLANK 30
int demarre_la_machine(char *pattern, char *outdir, int szfifo, int demarre_la_machine(char *pattern, char *outdir, int szfifo,
int infx, int outfx, int step) int outfx, int step)
{ {
int foo, idx; int foo, idx;
glob_t globbuf; glob_t globbuf;
@ -88,8 +87,6 @@ fprintf(stderr, "\tstep is %d\n", step);
(void)fimg_timer_set(0); (void)fimg_timer_set(0);
if (infx) fprintf(stderr, "\tin fx #%d\n", infx);
else fprintf(stderr, "\tno in fx\n");
if (outfx) fprintf(stderr, "\tout fx #%d\n", outfx); if (outfx) fprintf(stderr, "\tout fx #%d\n", outfx);
else fprintf(stderr, "\tno out fx\n"); else fprintf(stderr, "\tno out fx\n");
@ -113,6 +110,7 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
/* first step : read the current grabed picz from disk, /* first step : read the current grabed picz from disk,
and put it in our private buffer */ and put it in our private buffer */
foo = fimg_load_from_dump(cptr, &input); foo = fimg_load_from_dump(cptr, &input);
if (foo) { if (foo) {
fprintf(stderr, "load #%d from dump -> %d\n", idx, foo); fprintf(stderr, "load #%d from dump -> %d\n", idx, foo);
continue; continue;
@ -120,7 +118,8 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
/* ========================= */ /* ========================= */
/* FSCKING INPUT FILTER HERE */ /* FSCKING INPUT FILTER HERE */
foo = crapulator(&input, infx, 0.42);
foo = crapulator(&input, idx);
if (foo) { if (foo) {
fprintf(stderr, "%s crapulator -> %d\n", __func__, foo); fprintf(stderr, "%s crapulator -> %d\n", __func__, foo);
exit(1); exit(1);
@ -149,42 +148,26 @@ else {
return 8; return 8;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
void help(void)
{
puts("\tFONDERIE\noptions:");
puts("\t-g\tconvert to gray");
puts("\t-I\tinput glob pattern");
puts("\t-O\toutput directory");
puts("\t-T\tfifo size");
puts("\t-v\tincrease verbosity");
puts("\t-w\tinput effect");
puts("\t-x\toutput effect");
exit(0);
}
/* -------------------------------------------------------------- */
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
int foo, opt; int foo, opt;
int fifosize = 10; int fifosize = 10;
char *in_pattern = "capture/?????.fimg"; char *in_pattern = "capture/?????.fimg";
char *out_dir = "p8"; char *out_dir = "p8";
int in_effect = 0;
int out_effect = 0; int out_effect = 0;
int steps = 1; int steps = 1;
fprintf(stderr, "*** %s :\n\tcompiled by tTh, %s %s\n\tpid %d\n", // float maxlevel = 2500.0;
argv[0], __DATE__, __TIME__, getpid());
fprintf(stderr, "*** %s : compiled by tTh, %s %s\n", argv[0],
__DATE__, __TIME__);
fimg_print_version(2); fimg_print_version(2);
while ((opt = getopt(argc, argv, "ghI:O:s:T:vx:")) != -1) { while ((opt = getopt(argc, argv, "gI:O:s:T:vx:")) != -1) {
switch(opt) { switch(opt) {
case 'g': convert_to_gray = 1; case 'g': convert_to_gray = 1;
break; break;
case 'h': help();
break;
case 'I': in_pattern = optarg; case 'I': in_pattern = optarg;
break; break;
case 'O': out_dir = optarg; case 'O': out_dir = optarg;
@ -193,8 +176,6 @@ while ((opt = getopt(argc, argv, "ghI:O:s:T:vx:")) != -1) {
break; break;
case 'v': verbosity++; case 'v': verbosity++;
break; break;
case 'w': in_effect = atoi(optarg);
break;
case 'x': out_effect = atoi(optarg); case 'x': out_effect = atoi(optarg);
break; break;
case 's': steps = atoi(optarg); case 's': steps = atoi(optarg);
@ -202,8 +183,7 @@ while ((opt = getopt(argc, argv, "ghI:O:s:T:vx:")) != -1) {
} }
} }
foo = demarre_la_machine(in_pattern, out_dir, fifosize, in_effect, foo = demarre_la_machine(in_pattern, out_dir, fifosize, out_effect, steps);
out_effect, steps);
fprintf(stderr, "retour du big-run de la machine -> %d\n", foo); fprintf(stderr, "retour du big-run de la machine -> %d\n", foo);
return 0; return 0;

View File

@ -15,12 +15,11 @@
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
/* global vars from main /* global vars from main
*/ */
extern int verbosity; extern int verbosity;
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
/* -------------------------------------------------------------- */ int brotche_rand48(FloatImg *fimg, float ratio, float mval)
int brotche_rand48_a(FloatImg *fimg, float ratio, float mval)
{ {
int nbpix, todo, foo; int nbpix, todo, foo;
int x, y; int x, y;
@ -28,10 +27,9 @@ float fval;
nbpix = fimg->width * fimg->height; nbpix = fimg->width * fimg->height;
todo = (int)((float)nbpix * ratio); todo = (int)((float)nbpix * ratio);
if (verbosity > 1) {
fprintf(stderr, "%s: ratio %f nbpix %d todo %d\n", __func__, if (verbosity > 1)
ratio, nbpix, todo); fprintf(stderr, "ratio %f nbpix %d todo %d\n", ratio, nbpix, todo);
}
for (foo=0; foo<todo; foo++) for (foo=0; foo<todo; foo++)
{ {
@ -52,8 +50,9 @@ float fval;
nbpix = fimg->width * fimg->height; nbpix = fimg->width * fimg->height;
todo = (int)((float)nbpix * ratio); todo = (int)((float)nbpix * ratio);
if (verbosity > 1) { if (verbosity > 1) {
fprintf(stderr, "%s: ratio %f nbpix %d todo %d\n", __func__, fprintf(stderr, "ratio %f nbpix %d todo %d\n",
ratio, nbpix, todo); ratio, nbpix, todo);
} }
@ -70,7 +69,33 @@ for (foo=0; foo<todo; foo++)
return 0; return 0;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
/*
* OMG ! a Color Graphic Adaptor emulator :)
*/
int kill_colors_a(FloatImg *fimg, float fval)
{
int nbpix, foo;
if (FIMG_TYPE_RGB != fimg->type) {
fprintf(stderr, "%s: bad src type %d on %p\n", __func__,
fimg->type, fimg);
return -8;
}
nbpix = fimg->width * fimg->height;
for (foo=0; foo<nbpix; foo++) {
if (fimg->R[foo] > fimg->G[foo])
fimg->B[foo] = fimg->R[foo];
else
fimg->B[foo] = fimg->G[foo];
}
return 0;
}
/* -------------------------------------------------------------- */
/* -------------------------------------------------------------- */