diff --git a/Lib/Makefile b/Lib/Makefile index 9f4d8b5..67503a6 100644 --- a/Lib/Makefile +++ b/Lib/Makefile @@ -125,7 +125,6 @@ text1.o: text1.c $(DEPS) text16x24.o: text16x24.c $(DEPS) tga.o: tga.c $(DEPS) tools.o: tools.c $(DEPS) -trigo.o: trigo.c $(DEPS) turtle.o: turtle.c $(DEPS) vignetize.o: vignetize.c $(DEPS) @@ -174,7 +173,7 @@ OBJECTS = 7seg.o \ scale.o sobel4.o stereo.o \ tamppool.o tele_2.o television.o \ text0.o text1.o text16x24.o \ - tga.o tools.o trigo.o turtle.o \ + tga.o tools.o turtle.o \ vignetize.o \ warp0.o warp1.o warp2.o warp3.o \ zoom.o @@ -186,7 +185,7 @@ OBJECTS = 7seg.o \ #----------------------------------------------------------------- foo: foo.c $(DEPS) ../libtthimage.a - gcc $(CFLAGS) $< ../libtthimage.a -o $@ + gcc $(CFLAGS) $< ../libtthimage.a -lm -o $@ t_png: t_png.c $(DEPS) ../libtthimage.a gcc $(CFLAGS) $< ../libtthimage.a -lpng -lz -o $@ diff --git a/Lib/contrast.c b/Lib/contrast.c index 41dff67..77d903e 100644 --- a/Lib/contrast.c +++ b/Lib/contrast.c @@ -6,6 +6,48 @@ #include #include "../tthimage.h" + +/*::------------------------------------------------------------------::*/ +/* + * new: Fri Sep 15 20:18:35 UTC 2023 + * inspired by the sam func in FloatImg + */ +int Image_egalise_cos01(Image_Desc *source, Image_Desc *but, int k) +{ +unsigned char lut[256], uc; +int idx, x, y, pix, foo; +float fidx; + +fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, + source, but, k); + +if ( (foo=Image_compare_desc(source, but)) ) { + fprintf(stderr, "%s: images not compatible, %d\n", __func__, foo); + return foo; + } + +for (idx=0; idx<256; idx++) { + fidx = (float)idx / 255.0; + uc = (unsigned char)(255.0*(0.5 - 0.5 * cos(3.141592654*fidx))); + lut[idx] = uc; + /* printf("%7d %7d\n", idx, uc); */ + } + +for (y=0; yheight; y++) { + for (x=0; xwidth; x++) { + + pix = source->Rpix[y][x]; + but->Rpix[y][x] = lut[pix]; + pix = source->Gpix[y][x]; + but->Gpix[y][x] = lut[pix]; + pix = source->Bpix[y][x]; + but->Bpix[y][x] = lut[pix]; + + } + } + +return FULL_NUCKED; +} /*::------------------------------------------------------------------::*/ /* * cette fonction peut etre utilisee avec la meme image @@ -20,6 +62,10 @@ float fr, fg, fb; fprintf(stderr, "%s : %p -> %p\n", __func__, source, but); #endif +if (k) { + fprintf(stderr, "In %s, k must be 0, was %d\n", __func__, k); + } + if ( (foo=Image_compare_desc(source, but)) ) { fprintf(stderr, "%s : images are differents %d\n", __func__, foo); return foo; @@ -55,6 +101,10 @@ float fr, fg, fb; fprintf(stderr, "%s : %p -> %p\n", __func__, source, but); #endif +if (k) { + fprintf(stderr, "In %s, k must be 0, was %d\n", __func__, k); + } + if ( (foo=Image_compare_desc(source, but)) ) { fprintf(stderr, "%s : images are differents %d\n", __func__, foo); return foo; diff --git a/Lib/foo.c b/Lib/foo.c index 0489355..33c72d9 100644 --- a/Lib/foo.c +++ b/Lib/foo.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "../tthimage.h" @@ -14,6 +15,20 @@ else Image_t16x24_essai("16x24gruik", "0123456789abcdef", "16x24.tga"); return 0; } + +/* ============================== */ +void mk_lut(unsigned char lut[]) +{ +int idx, uc; +float fidx; + +for (idx=0; idx<256; idx++) { + fidx = (float)idx / 255.0; + uc = (unsigned char)(255.0*(0.5 - 0.5 * cos(3.141592654*fidx))); + lut[idx] = uc; + printf("%7d %7d\n", idx, uc); + } +} /* ============================== */ int essai_draw_paint_rect(char *outga) { @@ -62,7 +77,11 @@ return OLL_KORRECT; int main(int argc, char *argv[]) { int foo; +unsigned char Lut[256]; +mk_lut(Lut); + +#if 0 Image_print_version(2); Image_print_sizeof_structs("foo"); @@ -72,5 +91,8 @@ fprintf(stderr, "essai show t16x24 --> %d\n", foo); foo = essai_draw_paint_rect("foo.tga"); fprintf(stderr, "essai draw rect --> %d\n", foo); +Image_egalise_cos01(NULL, NULL, 0); +#endif + return 0; } diff --git a/Tools/tga_equalize.c b/Tools/tga_equalize.c index b102671..041476e 100644 --- a/Tools/tga_equalize.c +++ b/Tools/tga_equalize.c @@ -14,6 +14,7 @@ /*::------------------------------------------------------------------::*/ #define EQ_STD 4 #define EQ_GRAY 8 +#define EQ_COS01 9 #define EQ_2X2 12 #define EQ_LUMIN 14 #define EQ_SQUARE 16 @@ -26,6 +27,7 @@ mot_clef mots_clef[] = { "std", EQ_STD, "", "standard method" }, { "rgb", EQ_STD, "", "same as 'std'" }, { "gray", EQ_GRAY, "", "gray based" }, +{ "cos01", EQ_COS01, "", "cosinus 0->1" }, { "2x2", EQ_2X2, "", "2x2 matrix" }, { "lumin", EQ_LUMIN, "i", "param: ident is 256" }, /* { "gamma", EQ_GAMMA, "d", "not implemented" },*/ @@ -38,7 +40,7 @@ mot_clef mots_clef[] = /*::------------------------------------------------------------------::*/ void usage() { -fprintf(stderr, "* tga_equalize v 0.0.21 [%s] (dwtfywl) tonton Th\n", +fprintf(stderr, "* tga_equalize v 0.0.23 [%s] (dwtfywl) tonton Th\n", TGA_OUTILS_VERSION); fprintf(stderr, " compiled %s at %s\n", __DATE__, __TIME__); fprintf(stderr, "usage:\n\ttga_equalize avant.tga mode apres.tga [params]\n"); @@ -106,6 +108,10 @@ switch (commande) foo = Image_pix_sqroot(src, dst, 0); break; + case EQ_COS01: + foo = Image_egalise_cos01(src, dst, 0); + break; + case EQ_GAMMA: fprintf(stderr, "no gamma func in %d\n", getpid()); foo = FULL_NUCKED; diff --git a/tthimage.h b/tthimage.h index 46bee1c..91fd80d 100644 --- a/tthimage.h +++ b/tthimage.h @@ -4,7 +4,7 @@ http://la.buvette.org/devel/libimage/ */ #ifndef IMAGE_VERSION_STRING - #define IMAGE_VERSION_STRING "0.4.51 pl 46" + #define IMAGE_VERSION_STRING "0.4.51 pl 49" /*::------------------------------------------------------------------::*/ /* @@ -1192,6 +1192,8 @@ int Image_insert_with_alpha(Image_Desc *img, Image_Desc *ins, int foo); int Image_pix_square(Image_Desc *source, Image_Desc *but, int k); int Image_pix_sqroot(Image_Desc *source, Image_Desc *but, int k); +int Image_egalise_cos01(Image_Desc *source, Image_Desc *but, int k); + /*::------------------------------------------------------------------::*/ /* module levels.c new: Jan 2001