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_ALGORITHMS_COLOR_TO_GRAY_HPP
19 #define PIC_ALGORITHMS_COLOR_TO_GRAY_HPP
20 
21 #include "../base.hpp"
22 #include "../image.hpp"
23 #include "../image_vec.hpp"
24 #include "../filtering/filter_channel.hpp"
25 #include "../tone_mapping/exposure_fusion.hpp"
26 
27 namespace pic {
28 
29 
31 {
32 protected:
35 
36 public:
37 
39  {
40  ef.update(1.0f, 1.0f, 0.0f);
41  flt = new FilterChannel(SingleInt(0));
42  }
43 
45  {
46  delete_s(flt);
47  }
48 
49  Image* Process(Image *imgIn, Image *imgOut)
50  {
51  if(imgIn == NULL){
52  return imgOut;
53  }
54 
55  if(imgOut == NULL){
56  imgOut = new Image(1, imgIn->width, imgIn->height, 1);
57  }
58 
59  ImageVec img_vec;
60  ImageVec input = Single(imgIn);
61 
62  int channels = imgIn->channels;
63  for(int i = 0; i < channels; i++) {
64  img_vec.push_back(flt->Process(input, NULL));
65  flt->update(SingleInt(i + 1));
66  }
67 
68  imgOut = ef.Process(img_vec, imgOut);
69 
70  for(int i = 0; i < channels; i++) {
71  delete img_vec[i];
72  }
73 
74  stdVectorClear<Image>(img_vec);
75 
76  return imgOut;
77  }
78 
79  static Image* execute(Image* imgIn, Image *imgOut)
80  {
81  ColorToGray c2g;
82  imgOut = c2g.Process(imgIn, imgOut);
83 
84  return imgOut;
85  }
86 };
87 
88 
89 } // end namespace pic
90 
91 #endif /* PIC_ALGORITHMS_COLOR_TO_GRAY_HPP */
92 
Image * Process(ImageVec imgIn, Image *imgOut=NULL)
Process.
Definition: tone_mapping_operator.hpp:120
int channels
Definition: image.hpp:80
T * delete_s(T *data)
delete_s
Definition: std_util.hpp:123
Image * Process(Image *imgIn, Image *imgOut)
Definition: color_to_gray.hpp:49
std::vector< Image * > ImageVec
ImageVec an std::vector of pic::Image.
Definition: image_vec.hpp:29
virtual Image * Process(ImageVec imgIn, Image *imgOut)
Process.
Definition: filter.hpp:390
Definition: color_to_gray.hpp:30
The ExposureFusion class.
Definition: exposure_fusion.hpp:39
ColorToGray()
Definition: color_to_gray.hpp:38
FilterChannel * flt
Definition: color_to_gray.hpp:34
ExposureFusion ef
Definition: color_to_gray.hpp:33
~ColorToGray()
Definition: color_to_gray.hpp:44
void update(std::vector< int > channels_vec)
update
Definition: filter_channel.hpp:103
The FilterChannel class.
Definition: filter_channel.hpp:56
The Image class stores an image as buffer of float.
Definition: image.hpp:60
void update(float wC=1.0f, float wE=1.0f, float wS=1.0f)
update
Definition: exposure_fusion.hpp:196
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
PIC_INLINE std::vector< int > SingleInt(int v0)
SingleInt.
Definition: filter_channel.hpp:30
int width
Definition: image.hpp:80
int height
Definition: image.hpp:80
static Image * execute(Image *imgIn, Image *imgOut)
Definition: color_to_gray.hpp:79