Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages
deghosting/support.h
Go to the documentation of this file.00001 00021 #ifndef SUPPORT_H_ 00022 #define SUPPORT_H_ 00023 00024 #include "deghosting.h" 00025 00026 #include <vigra/functorexpression.hxx> 00027 // used in hugin_hdrmerge 00028 // FIXME: move it to the hugin_hdrmerge 00029 #include <vigra/combineimages.hxx> 00030 00031 namespace deghosting { 00032 00033 using namespace vigra; 00034 using namespace vigra::functor; 00035 00038 template <class PixelType> 00039 class LogarithmFunctor { 00040 public: 00041 LogarithmFunctor(PixelType off=0) : offset(off) {} 00042 00043 PixelType operator()(PixelType const& v) const { 00044 return std::log(v + offset); 00045 } 00046 protected: 00047 PixelType offset; 00048 }; 00049 00053 template <class ComponentType> 00054 class LogarithmFunctor<RGBValue<ComponentType> > { 00055 public: 00056 LogarithmFunctor(ComponentType off=0) : offset(off) {} 00057 00058 RGBValue<ComponentType> operator()(RGBValue<ComponentType> const& v) const { 00059 RGBValue<ComponentType> retVal; 00060 retVal[0] = log(v[0] + offset); 00061 retVal[1] = log(v[1] + offset); 00062 retVal[2] = log(v[2] + offset); 00063 //cout << retVal[0] << "," << retVal[1] << "," << retVal[2] << endl; 00064 return retVal; 00065 } 00066 protected: 00067 ComponentType offset; 00068 }; 00069 00073 template <class PixelType> 00074 class HatFunctor { 00075 public: 00076 HatFunctor() {} 00077 00078 PixelType operator()(PixelType v) const { 00079 PixelType t = (v/127.5 -1); 00080 t *= t; // ^2 00081 t *= t; // ^4 00082 t *= t; // ^8 00083 t *= t; // ^16 00084 return 1.0 - t; 00085 } 00086 }; 00087 00092 template <class ComponentType> 00093 class HatFunctor<RGBValue<ComponentType> > { 00094 public: 00095 HatFunctor() {} 00096 00097 ComponentType operator()(RGBValue<ComponentType> v) const { 00098 ComponentType t = (v.luminance()/127.5 -1); 00099 t *= t; // ^2 00100 t *= t; // ^4 00101 t *= t; // ^8 00102 t *= t; // ^16 00103 return 1.0 - t; 00104 } 00105 }; 00106 00109 template <class PixelType> 00110 class NormalizeFunctor { 00111 public: 00112 NormalizeFunctor(PixelType f) : factor(f) {} 00113 NormalizeFunctor(PixelType oldMaxValue, PixelType newMaxValue) : factor(newMaxValue/oldMaxValue) {} 00114 00115 PixelType operator()(PixelType const &v) const { 00116 return v*factor; 00117 } 00118 protected: 00119 PixelType factor; 00120 }; 00121 00125 template <class ComponentType> 00126 class NormalizeFunctor<RGBValue<ComponentType> > { 00127 public: 00128 NormalizeFunctor(RGBValue<ComponentType> oldMaxValue, RGBValue<ComponentType> newMaxValue) { 00129 // TODO 00130 } 00131 00132 RGBValue<ComponentType> operator()(RGBValue<ComponentType> const &v) { 00133 // TODO 00134 } 00135 protected: 00136 RGBValue<ComponentType> foo; 00137 }; 00138 00139 } // namespace deghosting 00140 00141 #endif /* SUPPORT_H_ */
1.3.9.1