PICCANTE  0.4
The hottest HDR imaging library!
filter_gradient_harris_opt.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_GRADIENT_HARRIS_OPT_HPP
19 #define PIC_FILTERING_FILTER_GRADIENT_HARRIS_OPT_HPP
20 
21 #include "../filtering/filter.hpp"
22 
23 namespace pic {
24 
29 {
30 protected:
32 
39  void ProcessBBox(Image *dst, ImageVec src, BBox *box);
40 
41 public:
42 
48 
53  void update(int colorChannel);
54 
63  void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)
64  {
65  width = imgIn[0]->width;
66  height = imgIn[0]->height;
67  channels = 3;
68  frames = imgIn[0]->frames;
69  }
70 
78  static Image *execute(Image *imgIn, Image *imgOut = NULL, int colorChannel = 0)
79  {
81  return filter.Process(Single(imgIn), imgOut);
82  }
83 };
84 
86 {
87  this->colorChannel = 0;
89 }
90 
92 {
93  if(colorChannel > -1) {
94  this->colorChannel = colorChannel;
95  }
96 }
97 
99  BBox *box)
100 {
101  Image *img = src[0];
102 
103  int channel = (img->channels == 1) ? 0 : colorChannel;
104 
105  for(int j = box->y0; j < box->y1; j++) {
106  for(int i = box->x0; i < box->x1; i++) {
107  float I_x = (*img)(i + 1, j)[channel] - (*img)(i - 1, j)[channel];
108  float I_y = (*img)(i, j + 1)[channel] - (*img)(i, j - 1)[channel];
109 
110  float *dst_data = (*dst)(i, j);
111 
112  dst_data[0] = I_x * I_x;
113  dst_data[1] = I_y * I_y;
114  dst_data[2] = I_x * I_y;
115  }
116  }
117 }
118 
119 } // end namespace pic
120 
121 #endif /* PIC_FILTERING_FILTER_GRADIENT_HARRIS_OPT_HPP */
The BBox class manages the creation of bounding boxes for images.
Definition: bbox.hpp:29
int colorChannel
Definition: filter_gradient_harris_opt.hpp:31
int channels
Definition: image.hpp:80
std::vector< Image * > ImageVec
ImageVec an std::vector of pic::Image.
Definition: image_vec.hpp:29
int x0
Definition: bbox.hpp:32
static Image * execute(Image *imgIn, Image *imgOut=NULL, int colorChannel=0)
execute
Definition: filter_gradient_harris_opt.hpp:78
The Filter class.
Definition: filter.hpp:50
virtual Image * Process(ImageVec imgIn, Image *imgOut)
Process.
Definition: filter.hpp:390
void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)
OutputSize.
Definition: filter_gradient_harris_opt.hpp:63
void update(int colorChannel)
update
Definition: filter_gradient_harris_opt.hpp:91
The FilterGradientHarrisOPT class.
Definition: filter_gradient_harris_opt.hpp:28
int y0
Definition: bbox.hpp:32
#define PIC_INLINE
Definition: base.hpp:33
The Image class stores an image as buffer of float.
Definition: image.hpp:60
FilterGradientHarrisOPT(int colorChannel)
FilterGradientHarrisOPT.
Definition: filter_gradient_harris_opt.hpp:85
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
void ProcessBBox(Image *dst, ImageVec src, BBox *box)
ProcessBBox.
Definition: filter_gradient_harris_opt.hpp:98