From e224ab83b6216811af030e762e87a53aba5335c4 Mon Sep 17 00:00:00 2001 From: tth Date: Wed, 18 May 2022 11:55:01 +0200 Subject: [PATCH] start of the fake colors module --- floatimg.h | 5 ++++- funcs/Makefile | 4 ++++ funcs/falsecolors.c | 39 +++++++++++++++++++++++++++++++++++++++ funcs/t.c | 10 +++++++--- funcs/tests.c | 34 +++++++++++++++++++++++++++++++++- funcs/tests.h | 1 + 6 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 funcs/falsecolors.c diff --git a/floatimg.h b/floatimg.h index a7739795..58df6dd4 100644 --- a/floatimg.h +++ b/floatimg.h @@ -5,7 +5,7 @@ * https://git.tetalab.org/tTh/FloatImg */ -#define FIMG_VERSION (186) +#define FIMG_VERSION (187) #define RELEASE_NAME ("noname") /* * in memory descriptor @@ -189,6 +189,9 @@ int fimg_mix_rgb_gray(FloatImg *img, float mix); int fimg_shift_to_zero(FloatImg *s, FloatImg *d, float coefs[6]); int fimg_auto_shift_to_zero(FloatImg *s, FloatImg *d); +/* funcs/falsecolors.c */ +int fimg_falsecolors_0(FloatImg *src, FloatImg *dst, int k, float valf); + /* --> funcs/plasmas.c */ int fimg_prototype_plasma(FloatImg *img, double time, int type); diff --git a/funcs/Makefile b/funcs/Makefile index 584edc8b..1ce197a3 100644 --- a/funcs/Makefile +++ b/funcs/Makefile @@ -9,6 +9,7 @@ DEPS = ../floatimg.h Makefile OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \ fimg-libpnm.o rampes.o rectangle.o \ sfx0.o sfx1.o sfx2.o sfx3.o sfx4.o \ + falsecolors.o \ geometry.o rotate.o fimg-openexr.o \ equalize.o fimg-fits.o saturation.o histogram.o \ fimg-dicom.o \ @@ -137,6 +138,9 @@ qsortrgb.o: qsortrgb.c $(DEPS) exporter.o: exporter.c $(DEPS) gcc $(COPT) -c $< +falsecolors.o: falsecolors.c $(DEPS) + gcc $(COPT) -c $< + hsv.o: hsv.c $(DEPS) gcc $(COPT) -c $< diff --git a/funcs/falsecolors.c b/funcs/falsecolors.c new file mode 100644 index 00000000..663dd985 --- /dev/null +++ b/funcs/falsecolors.c @@ -0,0 +1,39 @@ +/* + * FloatImg library from tTh - really ugly code inside + */ + +#include +#include +#include + +#include "../floatimg.h" + +/* -------------------------------------------------------------- */ +/* this is a global vars exported from main */ +extern int verbosity; + +/* -------------------------------------------------------------- */ + + +/* -------------------------------------------------------------- */ +/* nouveau 18 mai 2022 */ +int fimg_falsecolors_0(FloatImg *src, FloatImg *dst, int k, float valf) +{ +int x, y; + +fprintf(stderr, ">>> %s ( %p %p %d %f )\n", __func__, + src, dst, k, valf); + +for (y=0; yheight, y++) { + for (x=0; xwidth, x++) { + + /***********************/ + /* DO SOMETHING HERE ! */ + /***********************/ + + } + } + +return -1; +} +/* -------------------------------------------------------------- */ diff --git a/funcs/t.c b/funcs/t.c index 70d0c26d..96bb809b 100644 --- a/funcs/t.c +++ b/funcs/t.c @@ -25,7 +25,7 @@ enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff, Displace, ReadPNG, Plasmas, Hilight, OpenEXR, Geometrie, FileType, Mirror, KillRGB, Pixelize,SplitLevel, DecompRgbz, DecompRgbg, - Rectangle, Dicom }; + Rectangle, Dicom, Fakolor0, Fakolor3 }; typedef struct { char *name; int Cmd; @@ -60,6 +60,8 @@ Command commands[] = { { "decomprgbg", DecompRgbg }, { "rectangle", Rectangle }, { "dicom", Dicom }, + { "fakolor0", Fakolor0 }, + { "fakolor3", Fakolor3 }, { NULL, 0 } } ; @@ -248,7 +250,9 @@ switch(opt) { case Dicom: foo = essai_dicom(filename, outfile, 0); break; - + case Fakolor0: + foo = essai_0_fausses_couleurs(outfile, 0); + break; default: fprintf(stderr, "'%s' is a bad command\n", command); exit(1); @@ -256,7 +260,7 @@ switch(opt) { } if (foo) { - fprintf(stderr, "******* Essai --> %d\n", foo); + fprintf(stderr, "******* essai --> %d\n\n", foo); } fprintf(stderr, "++++++++++++ end of '%s' pid %d\n", command, getpid()); diff --git a/funcs/tests.c b/funcs/tests.c index df773f32..3d484689 100644 --- a/funcs/tests.c +++ b/funcs/tests.c @@ -18,6 +18,26 @@ extern int verbosity; /* --------------------------------------------------------------------- */ +/* nouveau 18 mai 2022 */ +int essai_0_fausses_couleurs(char *dstfile, int type) +{ +FloatImg src, dst; +int foo; + +#define W 1024 +#define H 768 +fprintf(stderr, "\nEssais fausses couleurs (type %d) -> '%s'\n", type, dstfile); + +foo = fimg_create(&src, W, H, FIMG_TYPE_RGB); +foo = fimg_hdeg_a(&src, 12e3); +foo = fimg_clone(&src, &dst, 0); +foo = fimg_clear(&dst); + +foo = fimg_falsecolors_0(&src, &dst, type, 3.141592654); + +foo= fimg_export_picture(&dst, dstfile, 0); +return -1; +} /* --------------------------------------------------------------------- */ int essai_dicom(char *inf, char *outf, int k) { @@ -41,6 +61,10 @@ FloatImg img; int foo; int rect[4]; +if (0 != k) { + fprintf(stderr, "in %s, k muste be 0, was %d\n", __func__, k); + } + foo = fimg_create(&img, 320, 240, FIMG_TYPE_RGB); fimg_drand48(&img, 1.0); @@ -741,6 +765,10 @@ int essai_geometrie(char *infile, int notused) FloatImg fimg, result; int foo; +if (0 != notused) { + fprintf(stderr, "in %s, k must be 0, was %d\n", __func__, notused); + } + if (NULL != infile) { fprintf(stderr, "loading %s\n", infile); foo = fimg_create_from_dump(infile, &fimg); @@ -879,13 +907,17 @@ int essai_mire(char *outname, int notused) FloatImg fimg; int re, foo; +if (0 != notused) { + fprintf(stderr, "in %s, k must be 0, was %d\n", __func__, notused); + } + fimg_create(&fimg, 1280, 960, FIMG_TYPE_RGB); re = fimg_test_pattern(&fimg, 9, 1.0); if (re) { fprintf(stderr, "fimg_test_pattern -> %d\n", re); } -foo = fimg_export_picture(&fimg, "mire.pnm", 0); +foo = fimg_export_picture(&fimg, outname, 0); fprintf(stderr, "in %s, export give a %d value\n", __func__, foo); return 0; diff --git a/funcs/tests.h b/funcs/tests.h index 1033a1cd..bca80982 100644 --- a/funcs/tests.h +++ b/funcs/tests.h @@ -28,6 +28,7 @@ int essai_geometrie(char *infile, int notused); int essai_detect_type(void); int fimg_essai_histo(FloatImg *src, char *outpic, int k); /* histogram.c */ int essai_histogramme(char *fname, int k); +int essai_0_fausses_couleurs(char *dstfile, int type); int essai_lecture_png(char *fname, char *outfile, int notused);