Browse Source

added "abs" func to fimgfx

master
tth 9 months ago
parent
commit
8c514ffe99
  1. 3
      floatimg.h
  2. 18
      lib/fimg-math.c
  3. 8
      tools/fimgfx.c

3
floatimg.h

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
* http://la.buvette.org/photos/cumul
*/
#define FIMG_VERSION 160
#define FIMG_VERSION 161
/*
* in memory descriptor
@ -223,6 +223,7 @@ int fimg_to_gray(FloatImg *head); @@ -223,6 +223,7 @@ int fimg_to_gray(FloatImg *head);
int fimg_add_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_absolute(FloatImg *fimg);
void fimg_drand48(FloatImg *fi, float kmul);
long fimg_count_negativ(FloatImg *fi);
long fimg_clamp_negativ(FloatImg *fi);

18
lib/fimg-math.c

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* fimg-core.c
* fimg-math.c
*
*
*/
@ -295,6 +295,22 @@ fimg_mul_cste(fi, coef); @@ -295,6 +295,22 @@ fimg_mul_cste(fi, coef);
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 */
void fimg_drand48(FloatImg *fi, float kmul)
{

8
tools/fimgfx.c

@ -27,7 +27,8 @@ typedef struct { @@ -27,7 +27,8 @@ typedef struct {
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_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[] = {
{ "cos01", Fx_cos01, 0, 1 },
@ -49,6 +50,7 @@ Fx fx_list[] = { @@ -49,6 +50,7 @@ Fx fx_list[] = {
{ "binarize", Fx_binarize, 0, 1 },
{ "trinarize", Fx_trinarize, 0, 1 },
{ "hilightr", Fx_hilight_R, 0, 1 },
{ "abs", Fx_absolute, 0, 0 },
{ NULL, 0, 0, 0 }
};
@ -231,6 +233,10 @@ switch (action) { @@ -231,6 +233,10 @@ switch (action) {
foo = fimg_highlight_color(&src, &dest, 'R', 1.333);
break;
case Fx_absolute:
fimg_copy_data(&src, &dest);
foo = fimg_absolute(&dest);
break;
default:
fprintf(stderr, "%s %s : %d is bad action\n",
__FILE__, __func__, action);

Loading…
Cancel
Save