FloatImg/lib/interpolate.c

51 lines
1.2 KiB
C
Raw Normal View History

2019-09-09 16:02:44 +02:00
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
#include "../floatimg.h"
int verbosity;
/* ---------------------------------------------------------------- */
2019-09-09 17:24:31 +02:00
static int gray_interpolate(FloatImg *s1, FloatImg *s2, FloatImg *d, float coef)
{
return -1;
}
/* ---------------------------------------------------------------- */
2019-09-09 16:02:44 +02:00
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;
}
2019-09-09 17:24:31 +02:00
picsize = d->width * d->height * 3;
2019-09-09 16:02:44 +02:00
for (idx=0; idx<picsize; idx++) {
d->R[idx] = (coef * s1->R[idx]) + ((1.0-coef) * s2->R[idx]);
}
2019-09-09 17:24:31 +02:00
return 0;
2019-09-09 16:02:44 +02:00
}
/* ---------------------------------------------------------------- */