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 "fonctions.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;
static int count = 0;
int flag_debug = 0;
float value;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d %f )\n", __func__,
image, idFx, fval);
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, image, notused);
#endif
if (666==count) {
flag_debug = 1;
fprintf(stderr, "DEBUG PT 1 in %s:%d\n", __func__, __LINE__);
fimg_save_as_png(image, "source.png", 0);
}
switch (idFx) {
case 0: /* DO NOTHING */
retval = 0; 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_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:
/* contour 2x2 don't work inplace */
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);
}
/* 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);
}
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);
}
/* and put back porcessed pixels */
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;
return 0;
}
/* -------------------------------------------------------------- */

View File

@ -2,5 +2,5 @@
* 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 "fonctions.h"
#include "crapulator.h"
/* -------------------------------------------------------------- */
/* global vars from main
@ -47,6 +46,104 @@ for (idx=0; idx<pfifo->nbslots; idx += step) {
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
@ -68,10 +165,9 @@ if (convert_to_gray) {
// 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) {
fprintf(stderr, "%s: ERR post process picture -> %d\n",
__func__, foo);
fprintf(stderr, "ERR post process picture -> %d\n", foo);
return foo;
}

View File

@ -40,8 +40,9 @@ int create_fifo(int nbslot, int w, int h, int t);
* 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 kill_colors_a(FloatImg *fimg, float fval);
int colors_brotcher(FloatImg *fimg, float fval);
/* -------------------------------------------------------------- */

View File

@ -12,7 +12,9 @@
#include "fonctions.h"
#include "crapulator.h"
int verbosity;
int convert_to_gray;
/* -------------------------------------------------------------- */
@ -30,15 +32,12 @@ if (foo) {
}
sprintf(ligne, "p8/%05d.png", numero);
/* ^^^
XXX hardcoded value ? wtf ?
*/
foo = export_fifo(ligne, proc, step);
if (foo) {
fprintf(stderr, "%s : err %d on export\n", __func__, foo);
return foo;
}
numero++; /* VERY IMPORTANT :) */
return 0;
@ -68,10 +67,10 @@ puts("");
return 0;
}
/* -------------------------------------------------------------- */
#define BLANK 40
#define BLANK 30
int demarre_la_machine(char *pattern, char *outdir, int szfifo,
int infx, int outfx, int step)
int outfx, int step)
{
int foo, idx;
glob_t globbuf;
@ -88,8 +87,6 @@ fprintf(stderr, "\tstep is %d\n", step);
(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);
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,
and put it in our private buffer */
foo = fimg_load_from_dump(cptr, &input);
if (foo) {
fprintf(stderr, "load #%d from dump -> %d\n", idx, foo);
continue;
@ -120,7 +118,8 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
/* ========================= */
/* FSCKING INPUT FILTER HERE */
foo = crapulator(&input, infx, 0.42);
foo = crapulator(&input, idx);
if (foo) {
fprintf(stderr, "%s crapulator -> %d\n", __func__, foo);
exit(1);
@ -149,42 +148,26 @@ else {
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 foo, opt;
int fifosize = 10;
char *in_pattern = "capture/?????.fimg";
char *out_dir = "p8";
int in_effect = 0;
int out_effect = 0;
int steps = 1;
fprintf(stderr, "*** %s :\n\tcompiled by tTh, %s %s\n\tpid %d\n",
argv[0], __DATE__, __TIME__, getpid());
// float maxlevel = 2500.0;
fprintf(stderr, "*** %s : compiled by tTh, %s %s\n", argv[0],
__DATE__, __TIME__);
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) {
case 'g': convert_to_gray = 1;
break;
case 'h': help();
break;
case 'I': in_pattern = optarg;
break;
case 'O': out_dir = optarg;
@ -193,8 +176,6 @@ while ((opt = getopt(argc, argv, "ghI:O:s:T:vx:")) != -1) {
break;
case 'v': verbosity++;
break;
case 'w': in_effect = atoi(optarg);
break;
case 'x': out_effect = atoi(optarg);
break;
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,
out_effect, steps);
foo = demarre_la_machine(in_pattern, out_dir, fifosize, out_effect, steps);
fprintf(stderr, "retour du big-run de la machine -> %d\n", foo);
return 0;

View File

@ -19,8 +19,7 @@ extern int verbosity;
/* -------------------------------------------------------------- */
/* -------------------------------------------------------------- */
int brotche_rand48_a(FloatImg *fimg, float ratio, float mval)
int brotche_rand48(FloatImg *fimg, float ratio, float mval)
{
int nbpix, todo, foo;
int x, y;
@ -28,10 +27,9 @@ float fval;
nbpix = fimg->width * fimg->height;
todo = (int)((float)nbpix * ratio);
if (verbosity > 1) {
fprintf(stderr, "%s: ratio %f nbpix %d todo %d\n", __func__,
ratio, nbpix, todo);
}
if (verbosity > 1)
fprintf(stderr, "ratio %f nbpix %d todo %d\n", ratio, nbpix, todo);
for (foo=0; foo<todo; foo++)
{
@ -52,8 +50,9 @@ float fval;
nbpix = fimg->width * fimg->height;
todo = (int)((float)nbpix * ratio);
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);
}
@ -70,7 +69,33 @@ for (foo=0; foo<todo; foo++)
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;
}
/* -------------------------------------------------------------- */
/* -------------------------------------------------------------- */