FloatImg/lib/interpolate.c
2019-09-09 16:02:44 +02:00

45 lines
1.0 KiB
C

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
#include "../floatimg.h"
int verbosity;
/* ---------------------------------------------------------------- */
int fimg_interpolate(FloatImg *s1, FloatImg *s2, FloatImg *d, float coef)
{
int picsize, idx;
if (FIMG_TYPE_RGB != s1->type) {
fprintf(stderr, "%s : bad src 1 type %d on %p\n", __func__,
s1->type, s1);
return -8;
}
if (FIMG_TYPE_RGB != s2->type) {
fprintf(stderr, "%s : bad src 2 type %d on %p\n", __func__,
s2->type, s2);
return -8;
}
if (FIMG_TYPE_RGB != d->type) {
fprintf(stderr, "%s : bad dst type %d on %p\n", __func__,
d->type, d);
return -9;
}
picsize = d->width * d->height * 2;
for (idx=0; idx<picsize; idx++) {
d->R[idx] = (coef * s1->R[idx]) + ((1.0-coef) * s2->R[idx]);
}
return -1;
}
/* ---------------------------------------------------------------- */