Compare commits

..

6 Commits

Author SHA1 Message Date
le vieux
e7c726320a tryng to really glitch my picz 2020-11-10 03:58:18 +01:00
le vieux
905c61628f to be done next week 2020-11-10 02:07:30 +01:00
le vieux
f5515b77a2 bumping the version, why not ? 2020-11-10 00:53:24 +01:00
le vieux
c3c5e0dc3f not a milestone 2020-11-10 00:50:25 +01:00
le vieux
538a8ffa82 importing the Interpolator for R325 project 2020-11-09 20:27:57 +01:00
le vieux
6b424ea72a patch Makefile fonderie 2020-11-09 18:32:29 +01:00
15 changed files with 316 additions and 26 deletions

1
.gitignore vendored
View File

@ -65,4 +65,5 @@ tools/*.tiff
Fonderie/*.o Fonderie/*.o
Fonderie/fonderie Fonderie/fonderie
Fonderie/interpolator

View File

@ -4,11 +4,17 @@
COPT = -g -no-pie -Wall -DDEBUG_LEVEL=0 -Werror=parentheses COPT = -g -no-pie -Wall -DDEBUG_LEVEL=0 -Werror=parentheses
LIBS = -lfloatimg -lpnglite -lm LIBS = -lfloatimg -lpnglite -lm
OBJS = fonctions.o sfx.o crapulator.o
DEPS = fonctions.h crapulator.h OBJS = fonctions.o sfx.o crapulator.o glitches.o metriques.o
DEPS = fonctions.h crapulator.h metriques.h glitches.h
all: fonderie interpolator
# ---------------------------------------------------------
fonderie: fonderie.c ${DEPS} ${OBJS} Makefile fonderie: fonderie.c ${DEPS} ${OBJS} Makefile
gcc ${COPT} $< ${OBJS} ${LIBS} -o $@ gcc ${COPT} $< ${OBJS} ${LIBS} -lz -o $@
crapulator.o: crapulator.c ${DEPS} Makefile crapulator.o: crapulator.c ${DEPS} Makefile
gcc ${COPT} -c $< gcc ${COPT} -c $<
@ -20,11 +26,17 @@ sfx.o: sfx.c ${DEPS} Makefile
gcc ${COPT} -c $< gcc ${COPT} -c $<
# --------------------------------------------------------- # ---------------------------------------------------------
#
# another way to brotch some pics...
#
TOTAR = *.c *.h Makefile \ metriques.o: metriques.[hc] Makefile
*.sh gcc ${COPT} -c $<
glitches.o: glitches.[hc] Makefile
gcc ${COPT} -c $<
interpolator: interpolator.c ${OBJS} Makefile
gcc ${COPT} $< ${OBJS} ${LIBS} -lz -o $@
# --------------------------------------------------------- # ---------------------------------------------------------

View File

@ -1,11 +1,11 @@
# Fonderie # Fonderie et Interpolator
Avec toutes ces fonctions disponibles et `grabvidseq`, nous Avec toutes ces fonctions disponibles et `grabvidseq`, nous
savons faire des images **floues***. L'étape suivante, les plus savons faire des images **floues***. L'étape suivante, les plus
pervers d'entre vous le savent déja, est celle de la création pervers d'entre vous le savent déja, est celle de la création
de **films flous**. de **films flous**.
## fonderie ## Fonderie
Le programme principal, utilisé à partir de la ligne de commande Le programme principal, utilisé à partir de la ligne de commande
avec une foule d'options aux mnémoniques abscons. avec une foule d'options aux mnémoniques abscons.
@ -65,5 +65,14 @@ aussi bien en entrée qu'en sortie. Il est, à l'heure actuelle,
assez rudimentaire, avec un paramétrage simpliste, et un manque assez rudimentaire, avec un paramétrage simpliste, et un manque
criant de documentation... criant de documentation...
## Interpolator
Un logiciel dont l'inspiration vient de Terre-Blanque, ça ne peut
pas être complètement malsain :)
## Conclusion
**Use the source, Luke** **Use the source, Luke**

View File

@ -11,7 +11,6 @@
#include "crapulator.h" #include "crapulator.h"
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
/* support function for the crapulator */
static int effect_3(FloatImg *image) static int effect_3(FloatImg *image)
{ {
float value; float value;
@ -76,7 +75,6 @@ if (666==count) {
switch (idFx) { switch (idFx) {
case 0: /* DO NOTHING */ case 0: /* DO NOTHING */
retval = 0; break; retval = 0; break;
case 1: case 1:
fimg_cos_01(image, image, fimg_cos_01(image, image,
fimg_get_maxvalue(image)); fimg_get_maxvalue(image));
@ -99,15 +97,12 @@ switch (idFx) {
case 6: case 6:
fimg_killcolors_a(image, 0.0); fimg_killcolors_a(image, 0.0);
break; break;
case 7: case 7:
retval = fimg_colors_mixer_a(image, 2.0); retval = fimg_colors_mixer_a(image, 2.0);
break; break;
case 8: case 8:
retval = insitu_ctr2x2(image); retval = insitu_ctr2x2(image);
break; break;
case 9: case 9:
retval = fimg_classif_trial(image, image, 0.37, 0); retval = fimg_classif_trial(image, image, 0.37, 0);
if (retval) { if (retval) {
@ -115,11 +110,13 @@ switch (idFx) {
exit(1); exit(1);
} }
break; break;
case 10: case 10:
retval = binarize(image, 0); retval = binarize(image, 0);
break; break;
case 11:
retval = trinarize(image, 0);
break;
/* --- WTF -- */
default : default :
fprintf(stderr, "%s : effect #%d invalid\n", fprintf(stderr, "%s : effect #%d invalid\n",
__func__, idFx); __func__, idFx);

View File

@ -40,6 +40,7 @@ int create_fifo(int nbslot, int w, int h, int t);
* funcs in 'sfx.c' * funcs in 'sfx.c'
*/ */
int trinarize(FloatImg *pimg, int notused);
int binarize(FloatImg *pimg, int notused); int binarize(FloatImg *pimg, int notused);
int brotche_rand48_a(FloatImg *fimg, float ratio, float mval); int brotche_rand48_a(FloatImg *fimg, float ratio, float mval);

View File

@ -155,7 +155,7 @@ else {
fprintf(stderr, "\nelapsed %.2f seconds\n", fin); fprintf(stderr, "\nelapsed %.2f seconds\n", fin);
} }
return 8; return 8; /* why 9 ? */
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
void help(void) void help(void)

51
Fonderie/glitches.c Normal file
View File

@ -0,0 +1,51 @@
/*
* glitches.c
*/
#include <stdio.h>
#include <stdlib.h>
#include "../floatimg.h"
extern int verbosity;
/* -------------------------------------------------------------- */
int kill_a_random_line(FloatImg *pvictime, float fval, int notused)
{
int line, xpos, offset;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pvictime, notused);
#endif
line = rand() % pvictime->height;
if (verbosity > 1) {
fprintf(stderr, "%s: try to kill line %d\n", __func__, line);
}
offset = pvictime->width * line;
for (xpos=offset; xpos<pvictime->width; xpos++) {
pvictime->R[offset] = fval;
pvictime->G[offset] = 0.0;
pvictime->B[offset] = fval;
}
return 0;
}
/* -------------------------------------------------------------- */
int kill_a_few_lines(FloatImg *who, float fval, int number)
{
int idx, foo;
/* Frag the pixels */
for (idx=0; idx<number; idx++) {
foo = kill_a_random_line(who, fval, 0);
if (foo) abort();
}
return foo;
}
/* -------------------------------------------------------------- */

9
Fonderie/glitches.h Normal file
View File

@ -0,0 +1,9 @@
/*
* glitches.h
*/
int kill_a_random_line(FloatImg *pvictime, float level, int notused);
int kill_a_few_lines(FloatImg *who, float fval, int number);
/* this is a wtf file */

151
Fonderie/interpolator.c Normal file
View File

@ -0,0 +1,151 @@
/*
* INTERPOLATOR 2070
*
* Don't use that software in real life !
*
* imported in FloatImg Mon Nov 9 19:08:57 CET 2020
*
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <glob.h>
#include "../floatimg.h"
#include "glitches.h"
#include "crapulator.h"
// XXX #include "fonctions.h"
int verbosity;
int convert_to_gray; /* needed by fonctions.c */
/* -------------------------------------------------------------- */
int interpolator(char *pattern, char *outdir, int Nsteps)
{
FloatImg A, B, Out, *pFirst, *pSecond;
glob_t globbuf;
int foo, idx, ipng, w, h, step;
int iarray[3];
char *cptr, line[200];
float coef;
fprintf(stderr, "\nfrom %s to %s with %d steps.\n", pattern, outdir, Nsteps);
memset(&globbuf, 0, sizeof(glob_t));
foo = glob(pattern, 0, NULL, &globbuf);
fprintf(stderr, "globbing '%s' -> %d, %ld files found\n",
pattern, foo, globbuf.gl_pathc);
if (0 == globbuf.gl_pathc) {
fprintf(stderr, "%s : no file found, aborting\n", __func__);
return -1;
}
foo = fimg_fileinfos(globbuf.gl_pathv[0], iarray);
w = iarray[0], h = iarray[1];
fprintf(stderr, "\tfirst image size : %dx%d\n", w, h);
fimg_create(&A, w, h, 3); pFirst = &A;
fimg_create(&B, w, h, 3); pSecond = &B;
fimg_create(&Out, w, h, 3);
ipng = 0;
for (idx=0; idx<globbuf.gl_pathc; idx++) {
cptr = globbuf.gl_pathv[idx];
/* read the next file in B */
fprintf(stderr, "loading %s\r", cptr);
foo = fimg_load_from_dump(cptr, &B);
if (foo) {
fprintf(stderr, "load #%d from dump -> %d\n", idx, foo);
continue;
}
/* here, we can insert the input filter */
/* OK try it ... */
foo = crapulator(&B, 0, 256.7);
if (foo) {
fprintf(stderr, "crapulator failure %d\n", foo);
exit(1);
}
for (step=0; step<Nsteps; step++) {
coef = (float)step / (float)Nsteps;
fimg_interpolate(pSecond, pFirst, &Out, coef);
/* here we can insert the output filter */
kill_a_few_lines(&Out, 3.14159, 500);
sprintf(line, "%s/%05d.png", outdir, ipng);
foo = fimg_save_as_png(&Out, line, 0);
if (foo) {
fprintf(stderr, "err saving %s\n", line);
return -8;
}
ipng++;
}
#if 1
/* temporary hack : move datas */
fimg_copy_data(&B, &A);
#else
/* swap pointers to the two picz */
pTmp = pSecond;
pSecond = pFirst;
pFirst = pTmp;
/* XXX THIS CODE DON'T WORK !!! */
#endif
}
fprintf(stderr, "generated %d png files\n", ipng);
return 0;
}
/* -------------------------------------------------------------- */
void help(void)
{
puts("\tINTERPOLATOR\noptions:");
/* may be we can make options incoherent, like
* the options of 'fonderie' software ?
*/
exit(0);
}
/* -------------------------------------------------------------- */
int main (int argc, char *argv[])
{
int foo;
int nbrsteps = 9;
int opt;
fprintf(stderr, "*** %s : compiled by tTh, %s %s\n", __FILE__,
__DATE__, __TIME__);
fimg_print_version(2);
while ((opt = getopt(argc, argv, "v")) != -1) {
switch(opt) {
case 'v': verbosity++; break;
}
}
/* TO BE CONTINUED *****/
if (4 != argc) {
fprintf(stderr, "args: <in globpattern> <out dir> <nbrsteep>\n");
exit(1);
}
nbrsteps = atoi(argv[3]);
foo = interpolator(argv[1], argv[2], nbrsteps);
fprintf(stderr, "interpolator give a %d score\n", foo);
return 0;
}
/* -------------------------------------------------------------- */

24
Fonderie/metriques.c Normal file
View File

@ -0,0 +1,24 @@
/*
* metriques.c
*/
#include <stdio.h>
#include "../floatimg.h"
extern int verbosity;
/* -------------------------------------------------------------- */
int get_float_metric(FloatImg *pimg, float *where, int whot)
{
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %f %d )\n", __func__, pimg, where, whot);
#endif
*where = 0;
return -1;
}
/* -------------------------------------------------------------- */

9
Fonderie/metriques.h Normal file
View File

@ -0,0 +1,9 @@
/*
* metriques.h
*/
/* -------------------------------------------------------------- */
int get_float_metric(FloatImg *pimg, float *where, int whot)
/* -------------------------------------------------------------- */

View File

@ -17,6 +17,15 @@
*/ */
extern int verbosity; extern int verbosity;
/* -------------------------------------------------------------- */
int trinarize(FloatImg *pimg, int notused)
{
fprintf(stderr, "the function '%s' is not implemented\n", __func__);
exit(2);
return -1;
}
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
int binarize(FloatImg *pimg, int notused) int binarize(FloatImg *pimg, int notused)
{ {
@ -100,6 +109,3 @@ return 0;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */

View File

@ -3,7 +3,7 @@
* ugly code from tTh * ugly code from tTh
*/ */
#define FIMG_VERSION 112 #define FIMG_VERSION 113
/* /*
* in memory descriptor * in memory descriptor

View File

@ -56,6 +56,7 @@ int to_gray = 0;
char *output_file = "out.fimg"; char *output_file = "out.fimg";
FloatImg accu, temp; FloatImg accu, temp;
int src_loaded = 0; int src_loaded = 0;
float vals[6];
g_width = g_height = 0; g_width = g_height = 0;
@ -74,11 +75,9 @@ fprintf(stderr, "argc = %d, optind = %d\n", argc, optind);
#endif #endif
for (idx=optind; idx<argc; idx++) { for (idx=optind; idx<argc; idx++) {
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%5d %s\n", idx, argv[idx]); fprintf(stderr, "%5d %s\n", idx, argv[idx]);
#endif #endif
foo = testfile(argv[idx]); foo = testfile(argv[idx]);
if (foo) { if (foo) {
fprintf(stderr, "testfile %s -> %d\n", argv[idx],foo); fprintf(stderr, "testfile %s -> %d\n", argv[idx],foo);
@ -98,12 +97,9 @@ for (idx=optind; idx<argc; idx++) {
} }
fimg_add_2(&temp, &accu); fimg_add_2(&temp, &accu);
} }
} }
if (to_gray) { if (to_gray) {
foo = fimg_desaturate(&accu, &accu, 0); foo = fimg_desaturate(&accu, &accu, 0);
if (foo) { if (foo) {
fprintf(stderr, "desaturate: error %d\n", foo); fprintf(stderr, "desaturate: error %d\n", foo);
@ -116,6 +112,21 @@ if (foo) {
exit(1); exit(1);
} }
if (verbosity) {
/* show some numbers about resultant picture */
foo = fimg_get_minmax_rgb(&accu, vals);
if (foo) {
fprintf(stderr, "err %d on fimg_get_minmax_rgb\n", foo);
return foo;
}
printf("Rmin %12.4g Rmax %12.4g delta %12g\n",
vals[0], vals[1], vals[1]-vals[0]);
printf("Gmin %12.4g Gmax %12.4g %12g\n",
vals[2], vals[3], vals[3]-vals[2]);
printf("Bmin %12.4g Bmax %12.4g %12g\n",
vals[4], vals[5], vals[5]-vals[4]);
}
return 0; return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */

View File

@ -1,5 +1,10 @@
/* /*
* PNG ---> FIMG * PNG ---> FIMG
*
* Attention : certains fichiers PNG ne passent pas cette
* moulinette, mais le bug est dans la bibliotheque de
* fonctions 'libpnglite'. Une solution de remplacement
* devrait etre a l'etude un de ces jours...
*/ */
#include <stdio.h> #include <stdio.h>
@ -17,6 +22,10 @@ int main(int argc, char *argv[])
FloatImg fimg; FloatImg fimg;
int foo; int foo;
/*
* pas de traitement des options ?
*/
if (3 != argc) { if (3 != argc) {
fimg_print_version(1); fimg_print_version(1);
fprintf(stderr, "usage:\n\t%s foo.png bar.fimg\n", argv[0]); fprintf(stderr, "usage:\n\t%s foo.png bar.fimg\n", argv[0]);
@ -31,7 +40,7 @@ if (foo) {
exit(1); exit(1);
} }
fimg_describe(&fimg, argv[2]); if (verbosity) fimg_describe(&fimg, argv[2]);
foo = fimg_dump_to_file(&fimg, argv[2], 0); foo = fimg_dump_to_file(&fimg, argv[2], 0);
fprintf(stderr, "save as fimg -> %d\n", foo); fprintf(stderr, "save as fimg -> %d\n", foo);