Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
BayerConverter.h
Go to the documentation of this file.
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.LGPL **
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 <ICLUtils/CompatMacros.h>
00034 #include <ICLCore/Img.h>
00035 #include <ICLUtils/Uncopyable.h>
00036 
00037 namespace icl {
00038   namespace core{
00039   
00041 
00043     class ICLCore_API BayerConverter : public utils::Uncopyable{
00044       public:
00045       
00046       enum bayerConverterMethod {
00047         nearestNeighbor = 0,
00048         simple,
00049         bilinear,
00050         hqLinear,
00051         edgeSense,
00052         vng
00053       };
00054       
00055       enum bayerPattern {
00056         bayerPattern_RGGB = 512,
00057         bayerPattern_GBRG,
00058         bayerPattern_GRBG,
00059         bayerPattern_BGGR
00060       };
00061       
00062       
00064       BayerConverter(const std::string &pattern="RGGB", 
00065                      const std::string &method="bilinear");
00066 
00068 
00070       BayerConverter(bayerPattern eBayerPattern, 
00071                      bayerConverterMethod eConvMethod=bilinear, 
00072                      const utils::Size &sizeHint = utils::Size::null);
00073       ~BayerConverter();
00074       
00076 
00077       void apply(const Img8u *src, ImgBase **dst);
00078       
00079       inline void setBayerPattern(bayerPattern eBayerPattern) { 
00080         m_eBayerPattern = eBayerPattern; 
00081       }
00082       
00083       inline void setConverterMethod(bayerConverterMethod eConvMethod) { 
00084         m_eConvMethod = eConvMethod; 
00085       }
00086       
00087       inline void setBayerPattern(const std::string &pattern){
00088         setBayerPattern(translateBayerPattern(pattern));
00089       }
00090 
00091       inline void setMethod(const std::string &method){
00092         setConverterMethod(translateBayerConverterMethod(method));
00093       }
00094 
00095       
00096       static std::string translateBayerConverterMethod(bayerConverterMethod ebcm);
00097       static bayerConverterMethod translateBayerConverterMethod(std::string sbcm);
00098       
00099       static std::string translateBayerPattern(bayerPattern ebp);
00100       static bayerPattern translateBayerPattern(std::string sbp);
00101       
00103 
00111       static void convert_bayer_to_gray(const Img8u &src, Img8u &dst, const std::string &pattern);
00112       
00113       private:
00115       std::vector<icl8u> m_buffer;
00116   
00117       bayerConverterMethod m_eConvMethod;
00118       bayerPattern m_eBayerPattern;
00119       #ifdef ICL_HAVE_IPP
00120         IppiBayerGrid m_IppBayerPattern;
00121       #endif
00122       
00123       // Interpolation methods
00124       void nnInterpolation(const Img8u *poBayerImg);
00125       void bilinearInterpolation(const Img8u *poBayerImg);
00126       void hqLinearInterpolation(const Img8u *poBayerImg);
00127       void edgeSenseInterpolation(const Img8u *poBayerImg);
00128       void simpleInterpolation(const Img8u *poBayerImg);
00129       #ifdef ICL_HAVE_IPP
00130         void nnInterpolationIpp(const Img8u *poBayerImg);
00131       #endif
00132       
00133       // Utility functions
00134       void clearBorders(icl8u *rgb, int sx, int sy, int w);
00135       inline void clip(int *iIn, icl8u *iOut) {
00136         *iOut = *iIn = *iIn < 0 ? 0 : *iIn > 255 ? 255 : 0;
00137       }
00138     };
00139    
00140   } // namespace core
00141 } // namespace icl
00142 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines