2022-05-18 11:55:01 +02:00
|
|
|
/*
|
|
|
|
* FloatImg library from tTh - really ugly code inside
|
2022-07-06 10:27:55 +02:00
|
|
|
*
|
|
|
|
* F A L S E C O L O R S
|
|
|
|
* or fake colors ?
|
2022-05-18 11:55:01 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2022-07-06 10:27:55 +02:00
|
|
|
#include <stdlib.h>
|
2022-05-18 11:55:01 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/time.h>
|
2022-07-06 10:27:55 +02:00
|
|
|
#include <math.h>
|
2022-05-18 11:55:01 +02:00
|
|
|
#include "../floatimg.h"
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------- */
|
|
|
|
/* this is a global vars exported from main */
|
|
|
|
extern int verbosity;
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------- */
|
2022-07-06 10:27:55 +02:00
|
|
|
/* TRUCS A VOIR
|
|
|
|
|
|
|
|
f(x,y) = (((y & x) * (y - x)) % ((21 & x) * (y | 8))) ^ (~((x & 7) | (x % x)))
|
2022-05-18 11:55:01 +02:00
|
|
|
|
|
|
|
|
2022-07-06 10:27:55 +02:00
|
|
|
*/
|
2022-05-18 11:55:01 +02:00
|
|
|
/* -------------------------------------------------------------- */
|
|
|
|
/* nouveau 18 mai 2022 */
|
2022-07-06 10:27:55 +02:00
|
|
|
/* please explain the meaning of 'valf' parameter */
|
2022-05-18 11:55:01 +02:00
|
|
|
int fimg_falsecolors_0(FloatImg *src, FloatImg *dst, int k, float valf)
|
|
|
|
{
|
2022-07-06 10:27:55 +02:00
|
|
|
int x, y, offset;
|
|
|
|
float r, g, b, gray, maxv;
|
2022-05-18 11:55:01 +02:00
|
|
|
|
2022-07-06 10:27:55 +02:00
|
|
|
#if DEBUG_LEVEL
|
2022-05-30 21:38:29 +02:00
|
|
|
fprintf(stderr, ">>> %s ( %p %p %d %f )\n", __func__,
|
2022-05-18 11:55:01 +02:00
|
|
|
src, dst, k, valf);
|
2022-07-06 10:27:55 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (k) {
|
|
|
|
fprintf(stderr, "%s : %d %f\n", __func__, k, valf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check validity of parameters */
|
|
|
|
if (FIMG_TYPE_RGB != dst->type) {
|
|
|
|
fprintf(stderr, "in %s, picz at %p is not valid\n",
|
|
|
|
__func__, dst);
|
|
|
|
abort();
|
|
|
|
/* BLAM! */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
maxv = fimg_get_plane_maxvalue(src, 'r');
|
|
|
|
fprintf(stderr, "%s: maxv of red plane = %f\n", __func__, maxv);
|
|
|
|
|
|
|
|
/* enter big loop */
|
|
|
|
offset = 0;
|
|
|
|
for (y=0; y<src->height; y++) {
|
|
|
|
for (x=0; x<src->width; x++) {
|
|
|
|
|
|
|
|
gray = src->R[offset];
|
2022-05-18 11:55:01 +02:00
|
|
|
|
2022-07-06 10:27:55 +02:00
|
|
|
if (gray < maxv/2.0) {
|
|
|
|
r = gray * 2.0;
|
|
|
|
g = 0.0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
r = 0.0;
|
|
|
|
g = gray * 2.0;
|
|
|
|
}
|
|
|
|
b = fmodf(gray*8.0, maxv);
|
2022-05-18 11:55:01 +02:00
|
|
|
|
2022-07-06 10:27:55 +02:00
|
|
|
dst->R[offset] = r;
|
|
|
|
dst->G[offset] = g;
|
|
|
|
dst->B[offset] = b;
|
2022-05-18 11:55:01 +02:00
|
|
|
|
2022-07-06 10:27:55 +02:00
|
|
|
/* and GOTO next pixel */
|
|
|
|
offset++;
|
2022-05-18 11:55:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-06 10:27:55 +02:00
|
|
|
return 0;
|
2022-05-18 11:55:01 +02:00
|
|
|
}
|
|
|
|
/* -------------------------------------------------------------- */
|