add "cos01" contrast adjustement

This commit is contained in:
tTh
2023-09-17 22:36:08 +02:00
parent bef1c6c5e3
commit 395b262c92
5 changed files with 84 additions and 5 deletions

View File

@@ -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 $@

View File

@@ -6,6 +6,48 @@
#include <math.h>
#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; y<source->height; y++) {
for (x=0; x<source->width; 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;

View File

@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include <math.h>
#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;
}