is filterstack really ok ?
This commit is contained in:
parent
b1e613276d
commit
62aa91e434
@ -1,26 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
FILTRES="5:6:13 2 5:6:8 4:25 8:13:13:7 10:1 25:25:25"
|
||||
FILTRES="5:6:13 2:2 5:9:8 4:25 8:13:13:7 10:1 25:25:25:25"
|
||||
|
||||
rm /tmp/fstack*.png
|
||||
|
||||
for F in $FILTRES
|
||||
do
|
||||
|
||||
I="/tmp/fstack"$F".png"
|
||||
I="/tmp/fstack-"$F".png"
|
||||
echo ; echo $I
|
||||
./t -F $F
|
||||
txt=$(printf "[%-10s]" $F)
|
||||
convert foo.png -pointsize 32 -kerning 0 \
|
||||
-fill Orange -undercolor Gray20 \
|
||||
convert foo.png -pointsize 28 -kerning 0 \
|
||||
-fill Gray80 -undercolor Gray20 \
|
||||
-font Courier-Bold \
|
||||
-annotate +20+40 "$txt" \
|
||||
-annotate +0+25 "$txt" \
|
||||
$I
|
||||
|
||||
done
|
||||
|
||||
convert -delay 100 /tmp/fstack*.png foo.gif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
convert -delay 150 /tmp/fstack*.png foo.gif
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../floatimg.h"
|
||||
#include "crapulator.h"
|
||||
@ -13,6 +14,9 @@
|
||||
// #define DEBUG_LEVEL 1
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
|
||||
extern int verbosity;
|
||||
|
||||
static FilterSlot *stack_slots;
|
||||
static int nbre_filters, idx_slot;
|
||||
/* -------------------------------------------------------------- */
|
||||
@ -67,10 +71,15 @@ idx_slot++;
|
||||
return 0;
|
||||
}
|
||||
/* -------------------------------------------------------------- */
|
||||
int filterstack_list(char *txt)
|
||||
int filterstack_list(const char *txt)
|
||||
{
|
||||
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);
|
||||
@ -92,13 +101,19 @@ int filterstack_run(FloatImg *target, int notused)
|
||||
int idx, foo;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %d)\n", __func__, target, notused);
|
||||
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++) {
|
||||
|
||||
fprintf(stderr, "%d : effect %2d on %p\n",
|
||||
idx, stack_slots[idx].numero, target);
|
||||
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);
|
||||
@ -113,7 +128,66 @@ 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;
|
||||
}
|
||||
/* ----------------------------------------------------------- */
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
int numero;
|
||||
int numero; /* id in rapulator */
|
||||
int ival;
|
||||
float fval;
|
||||
} FilterSlot;
|
||||
@ -13,9 +13,11 @@ int filterstack_init(int nbre);
|
||||
|
||||
int filterstack_add(int code, int ival, float fval);
|
||||
|
||||
int filterstack_list(char *txt); /* XXX */
|
||||
int filterstack_list(const char *txt); /* XXX */
|
||||
|
||||
int filterstack_run(FloatImg *target, int notused);
|
||||
|
||||
int load_stack_from_file(char *fname, int notused);
|
||||
|
||||
int parse_filter_chain(const char *argument);
|
||||
|
||||
|
@ -20,8 +20,7 @@
|
||||
#include "glitches.h"
|
||||
#include "crapulator.h"
|
||||
#include "metriques.h"
|
||||
|
||||
// XXX #include "fonctions.h"
|
||||
#include "filterstack.h"
|
||||
|
||||
int verbosity;
|
||||
int convert_to_gray; /* needed by fonctions.c */
|
||||
@ -73,14 +72,15 @@ for (idx=0; idx<nombre; idx++) {
|
||||
foo, filename);
|
||||
return -1;
|
||||
}
|
||||
if (verbosity > 1)
|
||||
fprintf(stderr, "%5d %s %f\n", idx, filename, metrique);
|
||||
if (verbosity)
|
||||
fprintf(stderr, "%5d %s %f\r", 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, %ld files found\n",
|
||||
pattern, foo, globbuf.gl_pathc);
|
||||
fprintf(stderr, "globbing '%s' -> %d, %d files found\n",
|
||||
pattern, foo, (int)globbuf.gl_pathc);
|
||||
if (0 == globbuf.gl_pathc) {
|
||||
fprintf(stderr, "%s : no file found, aborting\n", __func__);
|
||||
return -1;
|
||||
@ -125,7 +125,10 @@ if (0 == globbuf.gl_pathc) {
|
||||
|
||||
idx_values = NULL;
|
||||
foo = tentative_triage(&globbuf, &idx_values, sort);
|
||||
fprintf(stderr, "\tTRI of %p -> %d\n\n", idx_values, foo);
|
||||
if (foo) {
|
||||
fprintf(stderr, "sort of %p -> %d\n\n", idx_values, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
foo = fimg_fileinfos(globbuf.gl_pathv[0], iarray);
|
||||
if (FIMG_TYPE_RGB != iarray[2]) {
|
||||
@ -148,8 +151,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 / %5ld %s\r", idx,
|
||||
globbuf.gl_pathc, cptr);
|
||||
fprintf(stderr, "%5d / %5d %s\r", idx,
|
||||
(int)globbuf.gl_pathc, cptr);
|
||||
foo = fimg_load_from_dump(cptr, &B);
|
||||
if (foo) {
|
||||
fprintf(stderr, "load %s from dump -> %d\n", cptr, foo);
|
||||
@ -169,7 +172,19 @@ 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);
|
||||
// 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;
|
||||
}
|
||||
|
||||
if (foo) {
|
||||
fprintf(stderr, "\n%s: out fx %d failure %d\n",
|
||||
__func__, outfx, foo);
|
||||
@ -195,6 +210,10 @@ 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);
|
||||
@ -212,9 +231,10 @@ puts("usage:\n\tinterpolator [options] <inglob> <outdir> <nbsteep>");
|
||||
*/
|
||||
puts("options:");
|
||||
puts("\t-S nn\tmysterious sort");
|
||||
puts("\t-v\tincrease verbosity");
|
||||
puts("\t-F i:j\tfilter chain");
|
||||
puts("\t-w nn\tinput effect");
|
||||
puts("\t-x nn\toutput effect");
|
||||
puts("\t-v\tincrease verbosity");
|
||||
|
||||
exit(0);
|
||||
}
|
||||
@ -227,13 +247,15 @@ 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, "hS:vw:x:")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "F: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;
|
||||
@ -251,6 +273,14 @@ 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);
|
||||
|
132
Fonderie/t.c
132
Fonderie/t.c
@ -25,87 +25,13 @@ int convert_to_gray; /* WTF ? */
|
||||
|
||||
/* ----------------------------------------------------------- */
|
||||
|
||||
int essai_filterstack(FloatImg *pimg)
|
||||
{
|
||||
int foo;
|
||||
|
||||
|
||||
filterstack_list(__func__);
|
||||
|
||||
foo = filterstack_run(pimg, 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "filterstack run --> %d\n", foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* ----------------------------------------------------------- */
|
||||
int parse_filter_chain(const char *argument)
|
||||
{
|
||||
char *cptr;
|
||||
int value, foo;
|
||||
|
||||
fprintf(stderr, "\n%s: arg = '%s'\n", __func__, argument);
|
||||
|
||||
foo = filterstack_init(4);
|
||||
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;
|
||||
}
|
||||
/* ----------------------------------------------------------- */
|
||||
int help(void)
|
||||
{
|
||||
puts("yolo!");
|
||||
exit(0);
|
||||
}
|
||||
/* ----------------------------------------------------------- */
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int essai_filterstack(void)
|
||||
{
|
||||
int foo;
|
||||
FloatImg image;
|
||||
double debut, fin;
|
||||
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
|
||||
|
||||
parse_filter_chain(filterchain);
|
||||
filterstack_list(__func__);
|
||||
|
||||
foo = fimg_create_from_dump("mire.fimg", &image);
|
||||
if (foo) {
|
||||
@ -113,12 +39,16 @@ if (foo) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
srand(getpid());
|
||||
srand(getpid()); srand48(getpid());
|
||||
|
||||
debut = fimg_timer_set(TIMER);
|
||||
foo = essai_filterstack(&image);
|
||||
|
||||
foo = filterstack_run(&image, 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "essai filterstack --> %d\n", foo);
|
||||
fprintf(stderr, "filterstack run --> %d\n", foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
fin = fimg_timer_set(TIMER);
|
||||
|
||||
foo = fimg_save_as_png(&image, "foo.png", 0);
|
||||
@ -130,6 +60,50 @@ 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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user