Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
support.h
Go to the documentation of this file.
1 
21 #ifndef SUPPORT_H_
22 #define SUPPORT_H_
23 
24 #include "deghosting.h"
25 
26 #include <vigra/functorexpression.hxx>
27 // used in hugin_hdrmerge
28 // FIXME: move it to the hugin_hdrmerge
29 #include <vigra/combineimages.hxx>
30 
31 namespace deghosting {
32 
35 template <class PixelType>
37  public:
38  explicit LogarithmFunctor(PixelType off=0) : offset(off) {}
39 
40  PixelType operator()(PixelType const& v) const {
41  return std::log(v + offset);
42  }
43  protected:
44  PixelType offset;
45 };
46 
50 template <class ComponentType>
51 class LogarithmFunctor<vigra::RGBValue<ComponentType> > {
52  public:
53  explicit LogarithmFunctor(ComponentType off=0) : offset(off) {}
54 
55  vigra::RGBValue<ComponentType> operator()(vigra::RGBValue<ComponentType> const& v) const {
56  vigra::RGBValue<ComponentType> retVal;
57  retVal[0] = log(v[0] + offset);
58  retVal[1] = log(v[1] + offset);
59  retVal[2] = log(v[2] + offset);
60  //cout << retVal[0] << "," << retVal[1] << "," << retVal[2] << std::endl;
61  return retVal;
62  }
63  protected:
64  ComponentType offset;
65 };
66 
70 template <class PixelType>
71 class HatFunctor {
72  public:
74 
75  PixelType operator()(PixelType v) const {
76  PixelType t = (v/127.5 -1);
77  t *= t; // ^2
78  t *= t; // ^4
79  t *= t; // ^8
80  t *= t; // ^16
81  return 1.0 - t;
82  }
83 };
84 
89 template <class ComponentType>
90 class HatFunctor<vigra::RGBValue<ComponentType> > {
91  public:
93 
94  ComponentType operator()(vigra::RGBValue<ComponentType> v) const {
95  ComponentType t = (v.luminance()/127.5 -1);
96  t *= t; // ^2
97  t *= t; // ^4
98  t *= t; // ^8
99  t *= t; // ^16
100  return 1.0 - t;
101  }
102 };
103 
106 template <class PixelType>
108  public:
109  explicit NormalizeFunctor(PixelType f) : factor(f) {}
110  NormalizeFunctor(PixelType oldMaxValue, PixelType newMaxValue) : factor(newMaxValue/oldMaxValue) {}
111 
112  PixelType operator()(PixelType const &v) const {
113  return v*factor;
114  }
115  protected:
116  PixelType factor;
117 };
118 
122 template <class ComponentType>
123 class NormalizeFunctor<vigra::RGBValue<ComponentType> > {
124  public:
125  NormalizeFunctor(vigra::RGBValue<ComponentType> oldMaxValue, vigra::RGBValue<ComponentType> newMaxValue) {
126  // TODO
127  }
128 
129  vigra::RGBValue<ComponentType> operator()(vigra::RGBValue<ComponentType> const &v) {
130  // TODO
131  }
132  protected:
133  vigra::RGBValue<ComponentType> foo;
134 };
135 
136 } // namespace deghosting
137 
138 #endif /* SUPPORT_H_ */
vigra::RGBValue< ComponentType > operator()(vigra::RGBValue< ComponentType > const &v) const
Definition: support.h:55
PixelType operator()(PixelType v) const
Definition: support.h:75
NormalizeFunctor(vigra::RGBValue< ComponentType > oldMaxValue, vigra::RGBValue< ComponentType > newMaxValue)
Definition: support.h:125
Logarithm functor.
Definition: support.h:36
LogarithmFunctor(PixelType off=0)
Definition: support.h:38
NormalizeFunctor(PixelType f)
Definition: support.h:109
vigra::RGBValue< ComponentType > operator()(vigra::RGBValue< ComponentType > const &v)
Definition: support.h:129
Fuctor to normalize values.
Definition: support.h:107
NormalizeFunctor(PixelType oldMaxValue, PixelType newMaxValue)
Definition: support.h:110
ComponentType operator()(vigra::RGBValue< ComponentType > v) const
Definition: support.h:94
vigra::RGBValue< T, RIDX, GIDX, BIDX > log(vigra::RGBValue< T, RIDX, GIDX, BIDX > const &v)
component-wise logarithm
Definition: utils.h:209
Functor to apply mexican hat function returns very small values for input near to 0 or 255...
Definition: support.h:71
PixelType operator()(PixelType const &v) const
Definition: support.h:40
PixelType operator()(PixelType const &v) const
Definition: support.h:112