add cos010 to tga_equalize

This commit is contained in:
tTh 2024-04-09 22:20:46 +02:00
parent 96ddcfccaf
commit d9d2db45b0
3 changed files with 37 additions and 26 deletions

View File

@ -10,48 +10,53 @@
/*::------------------------------------------------------------------::*/
/*
* new: Fri Sep 15 20:18:35 UTC 2023
* inspired by the sam func in FloatImg
* inspired by the same func in FloatImg
*/
int Image_egalise_cos01(Image_Desc *source, Image_Desc *but, int k)
{
int lut[256], uc;
int idx, foo;
/* int x, y, pix; */
int lut[256], uc, idx, foo;
float fidx;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
source, but, k);
#endif
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); */
}
Image_LUT_mono(source, but, lut);
/*
* old original code, replaced...
*
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 FUNC_IS_BETA;
}
/*::------------------------------------------------------------------::*/
int Image_egalise_cos010(Image_Desc *source, Image_Desc *but, int k)
{
int lut[256], uc, idx, foo;
float fidx;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
source, but, k);
#endif
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*2.0)));
lut[idx] = uc;
/* printf("%7d %7d\n", idx, uc); */
}
*
* ... by a func from 'calculs.c'
*/
Image_LUT_mono(source, but, lut);
return FUNC_IS_BETA;

View File

@ -15,6 +15,7 @@
#define EQ_STD 4
#define EQ_GRAY 8
#define EQ_COS01 9
#define EQ_COS010 10
#define EQ_2X2 12
#define EQ_LUMIN 14
#define EQ_SQUARE 16
@ -28,6 +29,7 @@ mot_clef mots_clef[] =
{ "rgb", EQ_STD, "", "same as 'std'" },
{ "gray", EQ_GRAY, "", "gray based" },
{ "cos01", EQ_COS01, "", "cosinus 0->1" },
{ "cos010", EQ_COS010, "", "cosinus 0-1-0" },
{ "2x2", EQ_2X2, "", "2x2 matrix" },
{ "lumin", EQ_LUMIN, "i", "param: ident is 256" },
/* { "gamma", EQ_GAMMA, "d", "not implemented" },*/
@ -40,7 +42,7 @@ mot_clef mots_clef[] =
/*::------------------------------------------------------------------::*/
void usage()
{
fprintf(stderr, "* tga_equalize v 0.0.23 [%s] (dwtfywl) tonton Th\n",
fprintf(stderr, "* tga_equalize v 0.0.24 [%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");
@ -112,6 +114,10 @@ switch (commande)
foo = Image_egalise_cos01(src, dst, 0);
break;
case EQ_COS010:
foo = Image_egalise_cos010(src, dst, 0);
break;
case EQ_GAMMA:
fprintf(stderr, "no gamma func in %d\n", getpid());
foo = FULL_NUCKED;

View File

@ -4,7 +4,7 @@
http://la.buvette.org/devel/libimage/
*/
#ifndef IMAGE_VERSION_STRING
#define IMAGE_VERSION_STRING "0.4.51 pl 82"
#define IMAGE_VERSION_STRING "0.4.51 pl 85"
/*::------------------------------------------------------------------::*/
/*
@ -98,7 +98,7 @@ typedef struct {
} Image_Rect;
/*
* new 11 Jan 2003: a struc like an Image_Rect, but with
* new 11 Jan 2003: a struct like an Image_Rect, but with
* double precision floating point coords.
*/
typedef struct {
@ -121,7 +121,7 @@ typedef struct {
* memory descriptor for bits-planes
* 27 Dec 2001: c,a devient quoi, cette histoire de bitmaps ?
* 17 mars 2010: du code commence a venir...
*
* 12 février 2024, on a toujours rien vu.
*/
typedef struct {
unsigned int magic;
@ -1206,6 +1206,7 @@ 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);
int Image_egalise_cos010 (Image_Desc *source, Image_Desc *but, int k);
/*::------------------------------------------------------------------::*/
/*
@ -1319,7 +1320,6 @@ int Image_shift_y(Image_Desc *src, Image_Desc *dst, int oy);
int Image_center_rotate_xy(Image_Desc *src, Image_Desc *dst, double angle,
double x, double y);
/*::------------------------------------------------------------------::*/
/*::------------------------------------------------------------------::*/
/* anamorphose.c */