PICCANTE  0.4
The hottest HDR imaging library!
color_to_gray.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_GL_ALGORITHMS_COLOR_TO_GRAY_HPP
19 #define PIC_GL_ALGORITHMS_COLOR_TO_GRAY_HPP
20 
21 #include "../../util/std_util.hpp"
22 
23 #include "../../gl/image.hpp"
24 #include "../../gl/filtering/filter_channel.hpp"
25 #include "../../gl/tone_mapping/exposure_fusion.hpp"
26 
27 namespace pic {
28 
33 {
34 protected:
38 
39 public:
44  {
45  flt = NULL;
46  ef = NULL;
47  }
48 
50  {
51  delete_s(flt);
52  delete_s(ef);
53  }
54 
61  ImageGL execute(ImageGL *imgIn, ImageGL *imgOut)
62  {
63  if(imgIn == NULL){
64  return imgOut;
65  }
66 
67  if(imgIn->channels != 3) {
68  return imgOut;
69  }
70 
71  if(imgOut == NULL){
72  imgOut = new ImageGL(1, imgIn->width, imgIn->height, 1, IMG_GPU, GL_TEXTURE_2D);
73  }
74 
75  ImageGLVec input = SingleGL(imgIn);
76 
77  if(flt == NULL) {
78  flt = new FilterGLChannel(0);
79  }
80 
81  int channels = imgIn->channels;
82 
83  if(img_vec.empty()) {
84  for(int i = 0; i < channels; i++) {
85  img_vec.push_back(flt->Process(input, NULL));
86  flt->update(i + 1);
87  }
88  } else {
89  for(int i = 0; i < channels; i++) {
90  flt->Process(input, img_vec[i]);
91  flt->update(i + 1);
92  }
93  }
94 
95  if(ef == NULL) {
96  ef = new ExposureFusionGL(1.0f, 1.0f, 0.0f);
97  }
98 
99  imgOut = ef->ProcessStack(img_vec, imgOut);
100 
101  return imgOut;
102  }
103 
104 };
105 
106 } // end namespace pic
107 
108 #endif /* PIC_GL_ALGORITHMS_COLOR_TO_GRAY_HPP */
109 
int channels
Definition: filter_radial_basis_function.hpp:80
T * delete_s(T *data)
delete_s
Definition: std_util.hpp:123
~ColorToGrayGL()
Definition: color_to_gray.hpp:49
PIC_INLINE ImageGLVec SingleGL(ImageGL *img)
SingleGL creates a single for filters input.
Definition: image_vec.hpp:39
void update(int channel)
update
Definition: filter_channel.hpp:80
FilterGLChannel * flt
Definition: color_to_gray.hpp:35
The ImageGL class.
Definition: image.hpp:42
ImageGLVec img_vec
Definition: color_to_gray.hpp:37
ImageGL execute(ImageGL *imgIn, ImageGL *imgOut)
execute
Definition: color_to_gray.hpp:61
virtual ImageGL * Process(ImageGLVec imgIn, ImageGL *imgOut)
Process.
Definition: display.hpp:258
ColorToGrayGL()
ColorToGray.
Definition: color_to_gray.hpp:43
int width
Definition: filter_radial_basis_function.hpp:80
ExposureFusionGL * ef
Definition: color_to_gray.hpp:36
The ExposureFusionGL class.
Definition: exposure_fusion.hpp:37
Definition: bilateral_separation.hpp:25
ImageGL * ProcessStack(ImageGLVec imgIn, ImageGL *imgOut=NULL)
ProcessStack.
Definition: exposure_fusion.hpp:186
Definition: image.hpp:37
The FilterGLChannel class.
Definition: filter_channel.hpp:30
std::vector< ImageGL * > ImageGLVec
ImageGLVec an std::vector of pic::ImageGL.
Definition: image_vec.hpp:32
int height
Definition: filter_radial_basis_function.hpp:80
The ColorToGrayGL class.
Definition: color_to_gray.hpp:32