18 #ifndef PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_BILINEAR_HPP 19 #define PIC_IMAGE_SAMPLERS_IMAGE_SAMPLER_BILINEAR_HPP 21 #include "../image_samplers/image_sampler.hpp" 63 int ind0, ind1, ind2, ind3;
80 int t0 = iy * img->
width;
81 int t1 = iy1 * img->
width;
88 for(
int i = 0; i < img->
channels; i++) {
89 vOut[i] = Bilinear<float>(img->
data[ind0 + i],
111 x =
CLAMPi(x, 0.0f, 1.0f);
112 y =
CLAMPi(y, 0.0f, 1.0f);
113 t =
CLAMPi(t, 0.0f, 1.0f);
119 float pOut2x = floorf(x);
120 float pOut2y = floorf(y);
121 float pOut2z = floorf(t);
123 float deltax = x - pOut2x;
124 float deltay = y - pOut2y;
125 float deltaz = t - pOut2z;
128 int ix = int(pOut2x);
129 int iy = int(pOut2y);
130 int iz = int(pOut2z);
132 int ix1 = (ix + 1) % img->
width;
133 int iy1 = (iy + 1) % img->
height;
134 int iz1 = (iz + 1) % img->
frames;
138 for(
int i = 0; i < img->channels; i++) {
139 val[0] = Bilinear<float>(
140 *((*img)(ix, iy, iz) + i),
141 *((*img)(ix1, iy, iz) + i),
142 *((*img)(ix, iy, iz1) + i),
143 *((*img)(ix1, iy, iz1) + i),
146 val[1] = Bilinear<float>(
147 *((*img)(ix, iy1, iz) + i),
148 *((*img)(ix1, iy1, iz) + i),
149 *((*img)(ix, iy1, iz1) + i),
150 *((*img)(ix1, iy1, iz1) + i),
153 vOut[i] = val[0] + deltay * (val[1] - val[0]);
float * data
data is the main buffer where pixel values are stored.
Definition: image.hpp:91
int channels
Definition: image.hpp:80
void SampleImageUC(Image *img, float x, float y, float *vOut)
SampleImageUC samples an image in unnormalized coordinates [0,width-1]x[0,height-1].
Definition: image_sampler_bilinear.hpp:60
The ImageSampler class.
Definition: image_sampler.hpp:29
int frames
Definition: image.hpp:80
float height1f
Definition: image.hpp:84
void SampleImage(Image *img, float x, float y, float *vOut)
SampleImage samples an image in normalized coordiantes (0,1).
Definition: image_sampler_bilinear.hpp:42
The Image class stores an image as buffer of float.
Definition: image.hpp:60
#define CLAMPi(x, a, b)
Definition: math.hpp:81
Definition: bilateral_separation.hpp:25
#define CLAMP(x, a)
Definition: math.hpp:77
int width
Definition: image.hpp:80
void SampleImage(Image *img, float x, float y, float t, float *vOut)
SampleImage samples an image in uniform coordiantes.
Definition: image_sampler_bilinear.hpp:105
The ImageSamplerBilinear class.
Definition: image_sampler_bilinear.hpp:28
int height
Definition: image.hpp:80
float frames1f
Definition: image.hpp:84
ImageSamplerBilinear()
Definition: image_sampler_bilinear.hpp:31
float width1f
Definition: image.hpp:84