PICCANTE  0.4
The hottest HDR imaging library!
filter_mosaic.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_MOSAIC_HPP
19 #define PIC_FILTERING_FILTER_MOSAIC_HPP
20 
21 #include "../filtering/filter.hpp"
22 
23 namespace pic {
24 
28 class FilterMosaic: public Filter
29 {
30 protected:
31 
38  void ProcessBBox(Image *dst, ImageVec src, BBox *box)
39  {
40  if(src[0]->channels != 3){
41  return;
42  }
43 
44  int width = dst->width;
45  float *data = src[0]->data;
46 
47  for(int j = box->y0; j < box->y1; j++) {
48  int c = j * width;
49  int mody = j % 2;
50 
51  for(int i = box->x0; i < box->x1; i++) {
52  int modx = i % 2;
53 
54  //indecies
55  int c1 = c + i;
56  int c3 = c1 * 3;
57 
58  if(mody == 0 && modx == 0) { //Red
59  dst->data[c1] = data[c3];
60  }
61 
62  if(mody == 0 && modx == 1) { //Green
63  dst->data[c1] = data[c3 + 1];
64  }
65 
66  if(mody == 1 && modx == 0) { //Green
67  dst->data[c1] = data[c3 + 1];
68  }
69 
70  if(mody == 1 && modx == 1) { //Blue
71  dst->data[c1] = data[c3 + 2];
72  }
73  }
74  }
75  }
76 
77 public:
82  {
83 
84  }
85 
94  void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)
95  {
96  width = imgIn[0]->width;
97  height = imgIn[0]->height;
98  channels = 1;
99  frames = imgIn[0]->frames;
100  }
101 
108  static Image *execute(Image *imgIn, Image *imgOut)
109  {
110  FilterMosaic flt;
111  return flt.Process(Single(imgIn), imgOut);
112  }
113 };
114 
115 } // end namespace pic
116 
117 #endif /* PIC_FILTERING_FILTER_MOSAIC_HPP */
118 
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 Filter class.
Definition: filter.hpp:50
virtual Image * Process(ImageVec imgIn, Image *imgOut)
Process.
Definition: filter.hpp:390
void ProcessBBox(Image *dst, ImageVec src, BBox *box)
ProcessBBox.
Definition: filter_mosaic.hpp:38
static Image * execute(Image *imgIn, Image *imgOut)
execute
Definition: filter_mosaic.hpp:108
int y0
Definition: bbox.hpp:32
void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)
OutputSize.
Definition: filter_mosaic.hpp:94
The Image class stores an image as buffer of float.
Definition: image.hpp:60
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
The FilterMosaic class.
Definition: filter_mosaic.hpp:28
FilterMosaic()
FilterMosaic.
Definition: filter_mosaic.hpp:81
int width
Definition: image.hpp:80