2022-06-26 11:06:35 +02:00
|
|
|
/*
|
|
|
|
* contrast.c - 31 dec 2013
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
2022-06-28 12:25:31 +02:00
|
|
|
#include "../tthimage.h"
|
2022-06-26 11:06:35 +02:00
|
|
|
|
|
|
|
/*::------------------------------------------------------------------::*/
|
|
|
|
/*
|
|
|
|
* cette fonction peut etre utilisee avec la meme image
|
|
|
|
* en source et en destination.
|
|
|
|
*/
|
|
|
|
int Image_pix_square(Image_Desc *source, Image_Desc *but, int k)
|
|
|
|
{
|
|
|
|
int x, y, r, g, b, foo;
|
|
|
|
float fr, fg, fb;
|
|
|
|
|
|
|
|
#if DEBUG_LEVEL
|
|
|
|
fprintf(stderr, "%s : %p -> %p\n", __func__, source, but);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if ( (foo=Image_compare_desc(source, but)) ) {
|
|
|
|
fprintf(stderr, "%s : images are differents %d\n", __func__, foo);
|
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (y=0; y<source->height; y++) {
|
|
|
|
for (x=0; x<source->width; x++) {
|
|
|
|
fr = ((float)(source->Rpix[y])[x]) / 255.0;
|
|
|
|
fg = ((float)(source->Gpix[y])[x]) / 255.0;
|
|
|
|
fb = ((float)(source->Bpix[y])[x]) / 255.0;
|
|
|
|
r = (int)(fr * fr * 255.0);
|
|
|
|
g = (int)(fg * fg * 255.0);
|
|
|
|
b = (int)(fb * fb * 255.0);
|
|
|
|
(but->Rpix[y])[x] = r;
|
|
|
|
(but->Gpix[y])[x] = g;
|
|
|
|
(but->Bpix[y])[x] = b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FUNC_IS_BETA;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
|
|
|
/*
|
|
|
|
* cette fonction peut etre utilisee avec la meme image
|
|
|
|
* en source et en destination.
|
|
|
|
*/
|
|
|
|
int Image_pix_sqroot(Image_Desc *source, Image_Desc *but, int k)
|
|
|
|
{
|
|
|
|
int x, y, foo;
|
|
|
|
float fr, fg, fb;
|
|
|
|
|
|
|
|
#if DEBUG_LEVEL
|
|
|
|
fprintf(stderr, "%s : %p -> %p\n", __func__, source, but);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if ( (foo=Image_compare_desc(source, but)) ) {
|
|
|
|
fprintf(stderr, "%s : images are differents %d\n", __func__, foo);
|
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (y=0; y<source->height; y++) {
|
|
|
|
for (x=0; x<source->width; x++) {
|
|
|
|
fr = ((float)(source->Rpix[y])[x]) / 255.0;
|
|
|
|
fg = ((float)(source->Gpix[y])[x]) / 255.0;
|
|
|
|
fb = ((float)(source->Bpix[y])[x]) / 255.0;
|
|
|
|
(but->Rpix[y])[x] = (int)(sqrt(fr) * 255.0);
|
|
|
|
(but->Gpix[y])[x] = (int)(sqrt(fg) * 255.0);
|
|
|
|
(but->Bpix[y])[x] = (int)(sqrt(fb) * 255.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FUNC_IS_BETA;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|