PICCANTE  0.4
The hottest HDR imaging library!
filter_sampler_3d.hpp
Go to the documentation of this file.
1 /*
2 
3 PICCANTE
4 The hottest HDR imaging library!
5 http://vcg.isti.cnr.it/piccante
6 
7 Copyright (C) 2014
8 Visual Computing Laboratory - ISTI CNR
9 http://vcg.isti.cnr.it
10 First author: Francesco Banterle
11 
12 This Source Code Form is subject to the terms of the Mozilla Public
13 License, v. 2.0. If a copy of the MPL was not distributed with this
14 file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 
16 */
17 
18 #ifndef PIC_FILTERING_FILTER_SAMPLER_3D_HPP
19 #define PIC_FILTERING_FILTER_SAMPLER_3D_HPP
20 
21 #include "../filtering/filter.hpp"
22 #include "../image_samplers/image_sampler.hpp"
23 
24 namespace pic {
25 
29 class FilterSampler3D: public Filter
30 {
31 protected:
33 
40  void ProcessBBox(Image *dst, ImageVec src, BBox *box);
41 
42 public:
49 
58  void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)
59  {
60  width = int(imgIn[0]->widthf * scale);
61  height = int(imgIn[0]->heightf * scale);
62  frames = int(imgIn[0]->framesf * scale);
63  channels = imgIn[0]->channels;
64  }
65 
73  static Image *execute(Image *in, ImageSampler *isb, float scale)
74  {
75  FilterSampler3D filterUp(scale, isb);
76  Image *out = filterUp.Process(Single(in), NULL);
77  return out;
78  }
79 };
80 
82 {
83  this->scale = scale;
84  this->isb = isb;
85 }
86 
88 {
89  Image *source = src[0];
90 
91  for(int p = box->z0; p < box->z1; p++) {
92  float t = float(p) / float(box->frames - 1);
93 
94  for(int j = box->y0; j < box->y1; j++) {
95  float y = float(j) / float(box->height - 1);
96 
97  for(int i = box->x0; i < box->x1; i++) {
98  float x = float(i) / float(box->width - 1);
99 
100  int c = p * source->tstride + j * source->ystride + i * source->xstride;
101 
102  isb->SampleImage(source, x, y, t, &dst->data[c]);
103  }
104  }
105  }
106 }
107 
108 } // end namespace pic
109 
110 #endif /* PIC_FILTERING_FILTER_SAMPLER_3D_HPP */
111 
void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)
OutputSize.
Definition: filter_sampler_3d.hpp:58
The BBox class manages the creation of bounding boxes for images.
Definition: bbox.hpp:29
float * data
data is the main buffer where pixel values are stored.
Definition: image.hpp:91
std::vector< Image * > ImageVec
ImageVec an std::vector of pic::Image.
Definition: image_vec.hpp:29
int x0
Definition: bbox.hpp:32
The ImageSampler class.
Definition: image_sampler.hpp:29
The Filter class.
Definition: filter.hpp:50
ImageSampler * isb
Definition: filter_sampler_3d.hpp:32
virtual Image * Process(ImageVec imgIn, Image *imgOut)
Process.
Definition: filter.hpp:390
float scale
Definition: filter_radial_basis_function.hpp:53
void ProcessBBox(Image *dst, ImageVec src, BBox *box)
ProcessBBox.
Definition: filter_sampler_3d.hpp:87
static Image * execute(Image *in, ImageSampler *isb, float scale)
execute
Definition: filter_sampler_3d.hpp:73
int y0
Definition: bbox.hpp:32
int xstride
Definition: image.hpp:82
#define PIC_INLINE
Definition: base.hpp:33
The Image class stores an image as buffer of float.
Definition: image.hpp:60
FilterSampler3D(float scale, ImageSampler *isb)
FilterSampler3D.
Definition: filter_sampler_3d.hpp:81
int ystride
Definition: image.hpp:82
PIC_INLINE ImageVec Single(Image *img)
Single creates an std::vector which contains img; this is for filters input.
Definition: image_vec.hpp:36
Definition: bilateral_separation.hpp:25
virtual void SampleImage(Image *img, float x, float y, float *vOut)
SampleImage samples an image in uniform coordiantes.
Definition: image_sampler.hpp:57
int tstride
Definition: image.hpp:82
int width
Definition: bbox.hpp:33
int height
Definition: bbox.hpp:33
int frames
Definition: bbox.hpp:33
int z0
Definition: bbox.hpp:32
The FilterSampler3D class.
Definition: filter_sampler_3d.hpp:29