added "abs" func to fimgfx

This commit is contained in:
tth 2021-11-02 16:01:11 +01:00
parent 2a1d74a83f
commit 8c514ffe99
3 changed files with 26 additions and 3 deletions

View File

@ -4,7 +4,7 @@
* http://la.buvette.org/photos/cumul * http://la.buvette.org/photos/cumul
*/ */
#define FIMG_VERSION 160 #define FIMG_VERSION 161
/* /*
* in memory descriptor * in memory descriptor
@ -223,6 +223,7 @@ int fimg_to_gray(FloatImg *head);
int fimg_add_cste(FloatImg *fi, float value); int fimg_add_cste(FloatImg *fi, float value);
int fimg_mul_cste(FloatImg *fi, float value); int fimg_mul_cste(FloatImg *fi, float value);
int fimg_ajust_from_grab(FloatImg *fi, double maxima, int notused); int fimg_ajust_from_grab(FloatImg *fi, double maxima, int notused);
int fimg_absolute(FloatImg *fimg);
void fimg_drand48(FloatImg *fi, float kmul); void fimg_drand48(FloatImg *fi, float kmul);
long fimg_count_negativ(FloatImg *fi); long fimg_count_negativ(FloatImg *fi);
long fimg_clamp_negativ(FloatImg *fi); long fimg_clamp_negativ(FloatImg *fi);

View File

@ -1,5 +1,5 @@
/* /*
* fimg-core.c * fimg-math.c
* *
* *
*/ */
@ -295,6 +295,22 @@ fimg_mul_cste(fi, coef);
return 0; return 0;
} }
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
int fimg_absolute(FloatImg *fi)
{
int surface, idx;
surface = fi->width * fi->height;
for (idx=0; idx<surface; idx++) {
fi->R[idx] = fabsf(fi->R[idx]);
fi->G[idx] = fabsf(fi->G[idx]);
fi->B[idx] = fabsf(fi->B[idx]);
}
return 0;
}
/* ---------------------------------------------------------------- */
/* Warning: this function is _very_ slow */ /* Warning: this function is _very_ slow */
void fimg_drand48(FloatImg *fi, float kmul) void fimg_drand48(FloatImg *fi, float kmul)
{ {

View File

@ -27,7 +27,8 @@ typedef struct {
enum fxid { Fx_cos01=5, Fx_cos010, Fx_pow2, Fx_sqrt, Fx_gray0, Fx_halfsz0, enum fxid { Fx_cos01=5, Fx_cos010, Fx_pow2, Fx_sqrt, Fx_gray0, Fx_halfsz0,
Fx_rot90, Fx_cmixa, Fx_desat, Fx_ctr2x2, Fx_norm, Fx_rot90, Fx_cmixa, Fx_desat, Fx_ctr2x2, Fx_norm,
Fx_classtrial, Fx_mirror, Fx_shift0, Fx_trimul, Fx_classtrial, Fx_mirror, Fx_shift0, Fx_trimul,
Fx_xper, Fx_binarize, Fx_trinarize,Fx_hilight_R }; Fx_xper, Fx_binarize, Fx_trinarize, Fx_hilight_R,
Fx_absolute };
Fx fx_list[] = { Fx fx_list[] = {
{ "cos01", Fx_cos01, 0, 1 }, { "cos01", Fx_cos01, 0, 1 },
@ -49,6 +50,7 @@ Fx fx_list[] = {
{ "binarize", Fx_binarize, 0, 1 }, { "binarize", Fx_binarize, 0, 1 },
{ "trinarize", Fx_trinarize, 0, 1 }, { "trinarize", Fx_trinarize, 0, 1 },
{ "hilightr", Fx_hilight_R, 0, 1 }, { "hilightr", Fx_hilight_R, 0, 1 },
{ "abs", Fx_absolute, 0, 0 },
{ NULL, 0, 0, 0 } { NULL, 0, 0, 0 }
}; };
@ -231,6 +233,10 @@ switch (action) {
foo = fimg_highlight_color(&src, &dest, 'R', 1.333); foo = fimg_highlight_color(&src, &dest, 'R', 1.333);
break; break;
case Fx_absolute:
fimg_copy_data(&src, &dest);
foo = fimg_absolute(&dest);
break;
default: default:
fprintf(stderr, "%s %s : %d is bad action\n", fprintf(stderr, "%s %s : %d is bad action\n",
__FILE__, __func__, action); __FILE__, __func__, action);