Image Component Library (ICL)
|
00001 /******************************************************************** 00002 ** Image Component Library (ICL) ** 00003 ** ** 00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld ** 00005 ** Neuroinformatics Group ** 00006 ** Website: www.iclcv.org and ** 00007 ** http://opensource.cit-ec.de/projects/icl ** 00008 ** ** 00009 ** File : ICLCore/src/ICLCore/BayerConverter.h ** 00010 ** Module : ICLCore ** 00011 ** Authors: Michael Goetting, Felix Reinhard, Christof Elbrechter ** 00012 ** ** 00013 ** ** 00014 ** GNU LESSER GENERAL PUBLIC LICENSE ** 00015 ** This file may be used under the terms of the GNU Lesser General ** 00016 ** Public License version 3.0 as published by the ** 00017 ** ** 00018 ** Free Software Foundation and appearing in the file LICENSE.GPL ** 00019 ** included in the packaging of this file. Please review the ** 00020 ** following information to ensure the license requirements will ** 00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt ** 00022 ** ** 00023 ** The development of this software was supported by the ** 00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** 00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** 00026 ** Forschungsgemeinschaft (DFG) in the context of the German ** 00027 ** Excellence Initiative. ** 00028 ** ** 00029 ********************************************************************/ 00030 00031 #pragma once 00032 00033 #include <ICLCore/Img.h> 00034 #include <ICLUtils/Uncopyable.h> 00035 00036 namespace icl { 00037 namespace core{ 00038 00040 00042 class BayerConverter : public utils::Uncopyable{ 00043 public: 00044 00045 enum bayerConverterMethod { 00046 nearestNeighbor = 0, 00047 simple, 00048 bilinear, 00049 hqLinear, 00050 edgeSense, 00051 vng 00052 }; 00053 00054 enum bayerPattern { 00055 bayerPattern_RGGB = 512, 00056 bayerPattern_GBRG, 00057 bayerPattern_GRBG, 00058 bayerPattern_BGGR 00059 }; 00060 00062 00064 BayerConverter(bayerConverterMethod eConvMethod, 00065 bayerPattern eBayerPattern, 00066 utils::Size sizeHint = utils::Size::null); 00067 ~BayerConverter(); 00068 00070 00071 void apply(const Img8u *src, ImgBase **dst); 00072 00073 inline void setBayerPattern(bayerPattern eBayerPattern) { 00074 m_eBayerPattern = eBayerPattern; 00075 } 00076 00077 inline void setConverterMethod(bayerConverterMethod eConvMethod) { 00078 m_eConvMethod = eConvMethod; 00079 } 00080 00081 static std::string translateBayerConverterMethod(bayerConverterMethod ebcm); 00082 static bayerConverterMethod translateBayerConverterMethod(std::string sbcm); 00083 00084 static std::string translateBayerPattern(bayerPattern ebp); 00085 static bayerPattern translateBayerPattern(std::string sbp); 00086 00087 private: 00089 std::vector<icl8u> m_buffer; 00090 00091 bayerConverterMethod m_eConvMethod; 00092 bayerPattern m_eBayerPattern; 00093 #ifdef HAVE_IPP 00094 IppiBayerGrid m_IppBayerPattern; 00095 #endif 00096 00097 // Interpolation methods 00098 void nnInterpolation(const Img8u *poBayerImg); 00099 void bilinearInterpolation(const Img8u *poBayerImg); 00100 void hqLinearInterpolation(const Img8u *poBayerImg); 00101 void edgeSenseInterpolation(const Img8u *poBayerImg); 00102 void simpleInterpolation(const Img8u *poBayerImg); 00103 #ifdef HAVE_IPP 00104 void nnInterpolationIpp(const Img8u *poBayerImg); 00105 #endif 00106 00107 // Utility functions 00108 void clearBorders(icl8u *rgb, int sx, int sy, int w); 00109 inline void clip(int *iIn, icl8u *iOut) { 00110 *iOut = *iIn = *iIn < 0 ? 0 : *iIn > 255 ? 255 : 0; 00111 } 00112 }; 00113 00114 } // namespace core 00115 } // namespace icl 00116