65 lines
1.1 KiB
C
65 lines
1.1 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
|
|
#include "../floatimg.h"
|
|
|
|
extern int verbosity;
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
int fimg_square_root(FloatImg *s, FloatImg *d, double maxval)
|
|
{
|
|
int nbre, idx;
|
|
double dval;
|
|
|
|
if (s->type != FIMG_TYPE_RGB) {
|
|
fprintf(stderr, "%s : type %d invalide\n",
|
|
__func__, s->type);
|
|
return -4;
|
|
}
|
|
|
|
if (NULL==d) {
|
|
d = s;
|
|
}
|
|
|
|
|
|
nbre = s->width * s->height * 3;
|
|
|
|
for (idx=0; idx<nbre; idx++) {
|
|
dval = s->R[idx] / maxval;
|
|
d->R[idx] = maxval * sqrt(dval);
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
/* ---------------------------------------------------------------- */
|
|
int fimg_power_2(FloatImg *s, FloatImg *d, double maxval)
|
|
{
|
|
int nbre, idx;
|
|
double dval;
|
|
|
|
if (s->type != FIMG_TYPE_RGB) {
|
|
fprintf(stderr, "%s : type %d invalide\n",
|
|
__func__, s->type);
|
|
return -4;
|
|
}
|
|
|
|
if (NULL==d) {
|
|
d = s;
|
|
}
|
|
|
|
|
|
nbre = s->width * s->height * 3;
|
|
|
|
for (idx=0; idx<nbre; idx++) {
|
|
dval = s->R[idx] / maxval;
|
|
d->R[idx] = maxval * dval * dval;
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
/* ---------------------------------------------------------------- */
|