Compare commits

..

No commits in common. "62aa91e434d93412a2f9db5f2d5623d106ffb2c4" and "11b1d996e88e872f7ab22fd8a00c8fca79de9895" have entirely different histories.

6 changed files with 80 additions and 216 deletions

View File

@ -1,22 +1,17 @@
#!/bin/bash
FILTRES="5:6:13 2:2 5:9:8 4:25 8:13:13:7 10:1 25:25:25:25"
OUTF='/tmp/out_a*.png'
rm /tmp/fstack*.png
rm $OUTF
make t && ./t
A_PART=$(ls -1 $OUTF)
Z_PART=$(ls -r1 $OUTF)
convert -delay 10 ${A_PART} ${Z_PART} foo.gif
for F in $FILTRES
do
I="/tmp/fstack-"$F".png"
echo ; echo $I
./t -F $F
txt=$(printf "[%-10s]" $F)
convert foo.png -pointsize 28 -kerning 0 \
-fill Gray80 -undercolor Gray20 \
-font Courier-Bold \
-annotate +0+25 "$txt" \
$I
done
convert -delay 150 /tmp/fstack*.png foo.gif

View File

@ -4,19 +4,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../floatimg.h"
#include "crapulator.h"
#include "filterstack.h"
// #undef DEBUG_LEVEL
// #define DEBUG_LEVEL 1
#undef DEBUG_LEVEL
#define DEBUG_LEVEL 1
/* -------------------------------------------------------------- */
extern int verbosity;
static FilterSlot *stack_slots;
static int nbre_filters, idx_slot;
/* -------------------------------------------------------------- */
@ -71,19 +67,12 @@ idx_slot++;
return 0;
}
/* -------------------------------------------------------------- */
int filterstack_list(const char *txt)
int filterstack_list(void)
{
int idx;
if (NULL==stack_slots) {
fprintf(stderr, "%s: NULL statck !\n", __func__);
exit(1);
}
fprintf(stderr, "------- %-20s --------\n", txt);
fprintf(stderr, "stack at %p, size %d, current %d\n",
stack_slots, nbre_filters, idx_slot);
fprintf(stderr, "idx fx# ival fval\n");
for (idx=0; idx<idx_slot; idx++) {
fprintf(stderr, "%3d %3d %3d %f\n", idx,
@ -104,19 +93,12 @@ int idx, foo;
fprintf(stderr, ">>> %s ( %p %d)\n", __func__, target, notused);
#endif
if (NULL==stack_slots) {
fprintf(stderr, "%s: NULL statck !\n", __func__);
exit(1);
}
for (idx=0; idx<idx_slot; idx++) {
if (verbosity > 1)
fprintf(stderr, "%d : effect %2d on %p\n",
idx, stack_slots[idx].numero, target);
foo = crapulator(target, stack_slots[idx].numero,
stack_slots[idx].fval);
foo = crapulator(target, stack_slots[idx].numero, 0.0);
if (foo) {
fprintf(stderr, "crapulator error %d\n", foo);
return foo;
@ -126,68 +108,3 @@ for (idx=0; idx<idx_slot; idx++) {
return 0;
}
/* -------------------------------------------------------------- */
int load_stack_from_file(char *fname, int notused)
{
FILE *fp;
// int a, b;
// float f;
// char line[100];
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused);
#endif
if (NULL==stack_slots) {
fprintf(stderr, "%s: NULL statck !\n", __func__);
exit(1);
}
if (NULL==(fp=fopen(fname, "r"))) {
perror(fname);
return -1;
}
/*
* here was dragons
*/
/* hadoc parser ? */
fclose(fp);
return -1;
}
/* -------------------------------------------------------------- */
int parse_filter_chain(const char *argument)
{
char *cptr;
int value, foo;
fprintf(stderr, "\n%s: arg = '%s'\n", __func__, argument);
foo = filterstack_init(8);
if (foo) {
fprintf(stderr, "%s: filterstack init --> %d\n", __func__, foo);
return foo;
}
for (;;) {
cptr = strtok(argument, ":");
// fprintf(stderr, "cptr %p\n", cptr);
if (NULL==cptr) break;
argument = NULL;
// fprintf(stderr, " parsing '%s'\n", cptr);
if (1 == sscanf(cptr, "%d", &value)) {
foo = filterstack_add(value, 1, 1.0);
if (foo) {
fprintf(stderr, "%s: err %d add\n",
__func__, foo);
}
}
}
if (verbosity) filterstack_list(__func__);
return 0;
}
/* ----------------------------------------------------------- */

View File

@ -3,7 +3,7 @@
*/
typedef struct {
int numero; /* id in rapulator */
int numero;
int ival;
float fval;
} FilterSlot;
@ -13,11 +13,6 @@ int filterstack_init(int nbre);
int filterstack_add(int code, int ival, float fval);
int filterstack_list(const char *txt); /* XXX */
int filterstack_list(void);
int filterstack_run(FloatImg *target, int notused);
int load_stack_from_file(char *fname, int notused);
int parse_filter_chain(const char *argument);

View File

@ -93,8 +93,8 @@ if (foo) {
exit(1);
}
fprintf(stderr, "glob '%s' -> %d, %d files found\n", pattern, foo,
(int)globbuf.gl_pathc);
fprintf(stderr, "glob '%s' -> %d, %ld files found\n", pattern, foo,
globbuf.gl_pathc);
/* get the size of the inputs images */
foo = fimg_fileinfos(globbuf.gl_pathv[0], datas);
@ -140,7 +140,7 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
fprintf(stderr, "traitement %s -> %d WTF?\n", cptr, foo);
break;
}
fprintf(stderr, "\t%5d / %5d\r", idx, (int)globbuf.gl_pathc);
fprintf(stderr, "\t%5d / %5ld\r", idx, globbuf.gl_pathc);
}
fputs("\n", stderr);

View File

@ -20,7 +20,8 @@
#include "glitches.h"
#include "crapulator.h"
#include "metriques.h"
#include "filterstack.h"
// XXX #include "fonctions.h"
int verbosity;
int convert_to_gray; /* needed by fonctions.c */
@ -72,15 +73,14 @@ for (idx=0; idx<nombre; idx++) {
foo, filename);
return -1;
}
if (verbosity)
fprintf(stderr, "%5d %s %f\r", idx, filename, metrique);
if (verbosity > 1)
fprintf(stderr, "%5d %s %f\n", idx, filename, metrique);
idxvalues[idx].idx = idx;
idxvalues[idx].value = metrique;
}
if (method) {
/* and now, we can massage all our datas */
fprintf(stderr, "sorting %d ...\n", method);
qsort(idxvalues, nombre, sizeof(IdxValue), cmp_idxvalues);
}
@ -116,8 +116,8 @@ fprintf(stderr, " interpolate from '%s' to '%s' with %d steps.\n",
memset(&globbuf, 0, sizeof(glob_t));
foo = glob(pattern, 0, NULL, &globbuf);
fprintf(stderr, "globbing '%s' -> %d, %d files found\n",
pattern, foo, (int)globbuf.gl_pathc);
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;
@ -125,10 +125,7 @@ if (0 == globbuf.gl_pathc) {
idx_values = NULL;
foo = tentative_triage(&globbuf, &idx_values, sort);
if (foo) {
fprintf(stderr, "sort of %p -> %d\n\n", idx_values, foo);
return foo;
}
fprintf(stderr, "\tTRI of %p -> %d\n\n", idx_values, foo);
foo = fimg_fileinfos(globbuf.gl_pathv[0], iarray);
if (FIMG_TYPE_RGB != iarray[2]) {
@ -151,8 +148,8 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
cptr = globbuf.gl_pathv[curpix]; /* aliasing filename */
/* read the next file in B */
fprintf(stderr, "%5d / %5d %s\r", idx,
(int)globbuf.gl_pathc, cptr);
fprintf(stderr, "%5d / %5ld %s\r", idx,
globbuf.gl_pathc, cptr);
foo = fimg_load_from_dump(cptr, &B);
if (foo) {
fprintf(stderr, "load %s from dump -> %d\n", cptr, foo);
@ -172,19 +169,7 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
fimg_interpolate(pSecond, pFirst, &Out, coef);
/* here we can insert the OUTPUT filter */
// foo = crapulator(&Out, outfx, value);
//if (foo) {
// fprintf(stderr, "\n%s: out fx %d failure %d\n",
// __func__, outfx, foo);
// exit(1);
// }
foo = filterstack_run(&Out, 0);
if (foo) {
fprintf(stderr, "run filt stk--> %d\n", foo);
return foo;
}
foo = crapulator(&Out, outfx, value);
if (foo) {
fprintf(stderr, "\n%s: out fx %d failure %d\n",
__func__, outfx, foo);
@ -210,10 +195,6 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
pFirst = pTmp;
/* XXX THIS CODE DON'T WORK !!! */
#endif
}
fprintf(stderr, "\ngenerated %d png files\n", ipng);
@ -231,10 +212,9 @@ puts("usage:\n\tinterpolator [options] <inglob> <outdir> <nbsteep>");
*/
puts("options:");
puts("\t-S nn\tmysterious sort");
puts("\t-F i:j\tfilter chain");
puts("\t-v\tincrease verbosity");
puts("\t-w nn\tinput effect");
puts("\t-x nn\toutput effect");
puts("\t-v\tincrease verbosity");
exit(0);
}
@ -247,15 +227,13 @@ int opt;
int inFx = 0;
int outFx = 0;
int sort = 0;
char *filterchain = "0";
fprintf(stderr, "*** %s : compiled by tTh, %s %s\n", __FILE__,
__DATE__, __TIME__);
fimg_print_version(2);
while ((opt = getopt(argc, argv, "F:hS:vw:x:")) != -1) {
while ((opt = getopt(argc, argv, "hS:vw:x:")) != -1) {
switch(opt) {
case 'F': filterchain = optarg; break;
case 'h': help(); break;
case 'S': sort = atoi(optarg); break;
case 'v': verbosity++; break;
@ -273,14 +251,6 @@ if (3 != (argc-optind)) {
exit(1);
}
foo = parse_filter_chain(filterchain);
if (foo) {
fprintf(stderr, "err %d parsing '%s'\n", foo, filterchain);
exit(1);
}
// filterstack_list(__FILE__);
nbrsteps = atoi(argv[optind+2]);
foo = interpolator(argv[optind], argv[optind+1], nbrsteps,
inFx, outFx, sort);

View File

@ -5,7 +5,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "../floatimg.h"
#include "glitches.h"
@ -18,37 +17,69 @@ int verbosity;
int convert_to_gray; /* WTF ? */
#define PNG "out.png"
#define W 800
#define H 600
#define LMAX 255.0
#define W 512
#define H 256
#define LMAX 249.9999
#define TIMER 1
/* ----------------------------------------------------------- */
int essai_filterstack(void)
int essai_filterstack(FloatImg *pimg)
{
int foo;
FloatImg image;
double debut, fin;
filterstack_list(__func__);
foo = fimg_create_from_dump("mire.fimg", &image);
foo = filterstack_init(4);
if (foo) {
fprintf(stderr, "err %d create image\n", foo);
exit(1);
fprintf(stderr, "filterstack init --> %d\n", foo);
return foo;
}
srand(getpid()); srand48(getpid());
foo = filterstack_add(5, 1, 1.0);
if (foo) {
fprintf(stderr, "filterstack add 1 --> %d\n", foo);
return foo;
}
foo = filterstack_add(13, 1, 1.0);
if (foo) {
fprintf(stderr, "filterstack add 2 --> %d\n", foo);
return foo;
}
debut = fimg_timer_set(TIMER);
filterstack_list();
foo = filterstack_run(&image, 0);
foo = filterstack_run(pimg, 0);
if (foo) {
fprintf(stderr, "filterstack run --> %d\n", foo);
return foo;
}
return 0;
}
/* ----------------------------------------------------------- */
int main(int argc, char *argv[])
{
int foo;
FloatImg image;
double debut, fin;
verbosity = 2;
fimg_print_version(1);
foo = fimg_create(&image, W, H, FIMG_TYPE_RGB);
if (foo) {
fprintf(stderr, "err %d create image\n", foo);
exit(1);
}
fimg_vdeg_a(&image, 255);
srand(getpid());
debut = fimg_timer_set(TIMER);
foo = essai_filterstack(&image);
if (foo) {
fprintf(stderr, "essai filterstack --> %d\n", foo);
}
fin = fimg_timer_set(TIMER);
foo = fimg_save_as_png(&image, "foo.png", 0);
@ -60,50 +91,6 @@ fprintf(stderr, "elapsed %f\n", fin-debut);
fimg_destroy(&image);
return 0;
}
/* ----------------------------------------------------------- */
int help(void)
{
puts("yolo!");
exit(0);
}
/* ----------------------------------------------------------- */
int main(int argc, char *argv[])
{
int foo;
int opt;
char *filterchain = "0";
fprintf(stderr, "*** %s : compiled by tTh, %s %s\n", __FILE__,
__DATE__, __TIME__);
fimg_print_version(2);
while ((opt = getopt(argc, argv, "hF:v")) != -1) {
switch(opt) {
case 'h': help(); break;
case 'F': filterchain = optarg; break;
case 'v': verbosity++; break;
}
}
#if DEBUG_LEVEL
fprintf(stderr, "%s : argc = %d, optind = %d\n", argv[0], argc, optind);
#endif
foo = parse_filter_chain(filterchain);
if (foo) {
fprintf(stderr, "err %d in parse_filter_chain\n", foo);
exit(1);
}
foo = essai_filterstack();
if (foo) {
fprintf(stderr, "err %d in essai_filterstack\n", foo);
exit(1);
}
return 0;
}