forked from tTh/FloatImg
boilerplate for plasmas
This commit is contained in:
parent
1b24c65877
commit
75f36c0f6a
@ -3,7 +3,7 @@
|
|||||||
* ugly code from tTh
|
* ugly code from tTh
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define FIMG_VERSION 116
|
#define FIMG_VERSION 117
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* in memory descriptor
|
* in memory descriptor
|
||||||
@ -126,11 +126,12 @@ int fimg_square_root(FloatImg *s, FloatImg *d, double maxval);
|
|||||||
int fimg_power_2(FloatImg *s, FloatImg *d, double maxval);
|
int fimg_power_2(FloatImg *s, FloatImg *d, double maxval);
|
||||||
int fimg_cos_01(FloatImg *s, FloatImg *d, double maxval);
|
int fimg_cos_01(FloatImg *s, FloatImg *d, double maxval);
|
||||||
int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval);
|
int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval);
|
||||||
|
|
||||||
|
|
||||||
int fimg_mix_rgb_gray(FloatImg *img, float mix);
|
int fimg_mix_rgb_gray(FloatImg *img, float mix);
|
||||||
int fimg_shift_to_zero(FloatImg *s, FloatImg *d, float coefs[6]);
|
int fimg_shift_to_zero(FloatImg *s, FloatImg *d, float coefs[6]);
|
||||||
|
|
||||||
|
/* --> funcs/plasmas.c */
|
||||||
|
int fimg_prototype_plasma(FloatImg *img, char *txt, int type);
|
||||||
|
|
||||||
/* * * * experimental ! */
|
/* * * * experimental ! */
|
||||||
int fimg_classif_trial(FloatImg *src, FloatImg*dst, float fval, int notused);
|
int fimg_classif_trial(FloatImg *src, FloatImg*dst, float fval, int notused);
|
||||||
int fimg_qsort_rgb_a(FloatImg *psrc, FloatImg *pdst, int notused);
|
int fimg_qsort_rgb_a(FloatImg *psrc, FloatImg *pdst, int notused);
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
|
|
||||||
COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=0
|
COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=1
|
||||||
DEPS = ../floatimg.h Makefile
|
DEPS = ../floatimg.h Makefile
|
||||||
|
|
||||||
OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \
|
OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \
|
||||||
fimg-libpnm.o rampes.o sfx0.o geometry.o rotate.o \
|
fimg-libpnm.o rampes.o sfx0.o geometry.o rotate.o \
|
||||||
equalize.o fimg-fits.o saturation.o histogram.o \
|
equalize.o fimg-fits.o saturation.o histogram.o \
|
||||||
hsv.o classif.o contour2x2.o qsortrgb.o exporter.o \
|
hsv.o classif.o contour2x2.o qsortrgb.o exporter.o \
|
||||||
displacement.o dithering.o
|
displacement.o dithering.o plasmas.o
|
||||||
|
|
||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
|
|
||||||
tests.o: tests.c tests.h $(DEPS)
|
|
||||||
gcc $(COPT) -c $<
|
|
||||||
|
|
||||||
t: t.c $(DEPS) ../libfloatimg.a tests.o
|
t: t.c $(DEPS) ../libfloatimg.a tests.o
|
||||||
gcc $(COPT) $< \
|
gcc $(COPT) $< \
|
||||||
tests.o \
|
tests.o \
|
||||||
@ -23,7 +20,11 @@ t: t.c $(DEPS) ../libfloatimg.a tests.o
|
|||||||
-ltiff \
|
-ltiff \
|
||||||
-lz -lm -o $@
|
-lz -lm -o $@
|
||||||
|
|
||||||
|
tests.o: tests.c tests.h $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
|
# upper-level functions
|
||||||
|
|
||||||
../libfloatimg.a: $(OBJS)
|
../libfloatimg.a: $(OBJS)
|
||||||
$(AR) r $@ $?
|
$(AR) r $@ $?
|
||||||
@ -67,6 +68,8 @@ equalize.o: equalize.c $(DEPS)
|
|||||||
dithering.o: dithering.c $(DEPS)
|
dithering.o: dithering.c $(DEPS)
|
||||||
gcc $(COPT) -c $<
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
plasmas.o: plasmas.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
sfx0.o: sfx0.c $(DEPS)
|
sfx0.o: sfx0.c $(DEPS)
|
||||||
gcc $(COPT) -c $<
|
gcc $(COPT) -c $<
|
||||||
|
29
funcs/t.c
29
funcs/t.c
@ -21,7 +21,7 @@ float global_fvalue;
|
|||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff,
|
enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff,
|
||||||
Histo, Hsv, Classif, Ctr2x2, Qsortrgb,
|
Histo, Hsv, Classif, Ctr2x2, Qsortrgb,
|
||||||
Displace, ReadPNG };
|
Displace, ReadPNG, Plasmas };
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *name;
|
char *name;
|
||||||
int Cmd;
|
int Cmd;
|
||||||
@ -43,6 +43,7 @@ Command commands[] = {
|
|||||||
{ "qsortrgb", Qsortrgb },
|
{ "qsortrgb", Qsortrgb },
|
||||||
{ "displace", Displace },
|
{ "displace", Displace },
|
||||||
{ "readpng", ReadPNG },
|
{ "readpng", ReadPNG },
|
||||||
|
{ "plasma", Plasmas },
|
||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
@ -64,7 +65,7 @@ void help(int k)
|
|||||||
{
|
{
|
||||||
Command *pcmd;
|
Command *pcmd;
|
||||||
|
|
||||||
fprintf(stderr, "usage:\n\t./t [options] command filename\n");
|
fprintf(stderr, "usage:\n\t./t [options] command [filename]\n");
|
||||||
|
|
||||||
fprintf(stderr, "options:\n");
|
fprintf(stderr, "options:\n");
|
||||||
fprintf(stderr, "\t-o outfile\n");
|
fprintf(stderr, "\t-o outfile\n");
|
||||||
@ -91,6 +92,7 @@ fprintf(stderr, "++++++++ compiled "__DATE__" at " __TIME__ "\n");
|
|||||||
global_fvalue = 1.0;
|
global_fvalue = 1.0;
|
||||||
outfile = "out.pnm";
|
outfile = "out.pnm";
|
||||||
command = "none";
|
command = "none";
|
||||||
|
filename = "in.fimg";
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "hk:o:p:v")) != -1) {
|
while ((opt = getopt(argc, argv, "hk:o:p:v")) != -1) {
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
@ -103,17 +105,22 @@ while ((opt = getopt(argc, argv, "hk:o:p:v")) != -1) {
|
|||||||
|
|
||||||
// fprintf(stderr, "argc %d optind %d\n", argc, optind);
|
// fprintf(stderr, "argc %d optind %d\n", argc, optind);
|
||||||
|
|
||||||
filename = NULL;
|
switch (argc-optind) {
|
||||||
if (2 != argc-optind) {
|
case 1: /* only command */
|
||||||
fprintf(stderr, "%s: bad command line\n", argv[0]);
|
command = argv[optind];
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
command = argv[optind];
|
||||||
|
filename = argv[optind+1];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "%s: bad command line ?\n", argv[0]);
|
||||||
help(1);
|
help(1);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
command = argv[optind];
|
|
||||||
filename = argv[optind+1];
|
|
||||||
|
|
||||||
if (verbosity) {
|
if (verbosity) {
|
||||||
fprintf(stderr, "%s : running command '%s' on '%s'\n",
|
fprintf(stderr, "++++++++ %s : running command '%s' on '%s'\n",
|
||||||
argv[0], command, filename);
|
argv[0], command, filename);
|
||||||
fprintf(stderr, "global fvalue : %f\n", global_fvalue);
|
fprintf(stderr, "global fvalue : %f\n", global_fvalue);
|
||||||
}
|
}
|
||||||
@ -163,6 +170,10 @@ switch(opt) {
|
|||||||
case ReadPNG:
|
case ReadPNG:
|
||||||
foo = essai_lecture_png(filename, outfile, 0);
|
foo = essai_lecture_png(filename, outfile, 0);
|
||||||
break;
|
break;
|
||||||
|
case Plasmas:
|
||||||
|
foo = essai_plasma(filename, outfile, 1, 13.37);
|
||||||
|
fprintf(stderr, "we are all plasmafields\n");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s : bad command\n", command);
|
fprintf(stderr, "%s : bad command\n", command);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -16,6 +16,35 @@
|
|||||||
|
|
||||||
extern int verbosity;
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int essai_plasma(char *infile, char *outfile, int ikoef, float fkoef)
|
||||||
|
{
|
||||||
|
FloatImg src, dst;
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' '%s' %d %g )\n", __func__,
|
||||||
|
infile, outfile, ikoef, fkoef);
|
||||||
|
|
||||||
|
/* if infile is loadable, use it for background */
|
||||||
|
foo = fimg_create_from_dump(infile, &src);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: error loading '%s'\n", __func__, infile);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
fprintf(stderr, "'%s' loaded\n", infile);
|
||||||
|
fimg_printhead(&src);
|
||||||
|
|
||||||
|
fimg_clone(&src, &dst, 1);
|
||||||
|
|
||||||
|
|
||||||
|
foo = fimg_export_picture(&dst, outfile, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
/* nouveau 24 octobre 2020, pendant le masque-flamme coronavidique */
|
/* nouveau 24 octobre 2020, pendant le masque-flamme coronavidique */
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
see also: t.c & tests.c
|
see also: t.c & tests.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
int essai_plasma(char *infile, char *outfile, int ikoef, float fkoef);
|
||||||
|
|
||||||
int essai_displacement(char *infile, char *outfile);
|
int essai_displacement(char *infile, char *outfile);
|
||||||
int essai_qsort_rgb(char *infile, char *outfile);
|
int essai_qsort_rgb(char *infile, char *outfile);
|
||||||
int essai_equalize(char *infile);
|
int essai_equalize(char *infile);
|
||||||
|
@ -188,9 +188,11 @@ if (foo) {
|
|||||||
return foo;
|
return foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* NO No no !!! don't do that !!! */
|
||||||
foo = fread(head->R, sizeof(float),
|
foo = fread(head->R, sizeof(float),
|
||||||
filehead.w*filehead.h*filehead.t, fp);
|
filehead.w*filehead.h*filehead.t, fp);
|
||||||
|
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user