Image Component Library (ICL)
BayerConverter.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLCore/src/ICLCore/BayerConverter.h **
10 ** Module : ICLCore **
11 ** Authors: Michael Goetting, Felix Reinhard, Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLCore/Img.h>
35 #include <ICLUtils/Uncopyable.h>
36 
37 namespace icl {
38  namespace core{
39 
41 
44  public:
45 
47  nearestNeighbor = 0,
52  vng
53  };
54 
55  enum bayerPattern {
56  bayerPattern_RGGB = 512,
59  bayerPattern_BGGR
60  };
61 
62 
64  BayerConverter(const std::string &pattern="RGGB",
65  const std::string &method="bilinear");
66 
68 
70  BayerConverter(bayerPattern eBayerPattern,
71  bayerConverterMethod eConvMethod=bilinear,
72  const utils::Size &sizeHint = utils::Size::null);
73  ~BayerConverter();
74 
76 
77  void apply(const Img8u *src, ImgBase **dst);
78 
79  inline void setBayerPattern(bayerPattern eBayerPattern) {
80  m_eBayerPattern = eBayerPattern;
81  }
82 
83  inline void setConverterMethod(bayerConverterMethod eConvMethod) {
84  m_eConvMethod = eConvMethod;
85  }
86 
87  inline void setBayerPattern(const std::string &pattern){
88  setBayerPattern(translateBayerPattern(pattern));
89  }
90 
91  inline void setMethod(const std::string &method){
92  setConverterMethod(translateBayerConverterMethod(method));
93  }
94 
95 
96  static std::string translateBayerConverterMethod(bayerConverterMethod ebcm);
97  static bayerConverterMethod translateBayerConverterMethod(std::string sbcm);
98 
99  static std::string translateBayerPattern(bayerPattern ebp);
100  static bayerPattern translateBayerPattern(std::string sbp);
101 
103 
111  static void convert_bayer_to_gray(const Img8u &src, Img8u &dst, const std::string &pattern);
112 
113  private:
115  std::vector<icl8u> m_buffer;
116 
119  #ifdef ICL_HAVE_IPP
120  IppiBayerGrid m_IppBayerPattern;
121  #endif
122 
123  // Interpolation methods
124  void nnInterpolation(const Img8u *poBayerImg);
125  void bilinearInterpolation(const Img8u *poBayerImg);
126  void hqLinearInterpolation(const Img8u *poBayerImg);
127  void edgeSenseInterpolation(const Img8u *poBayerImg);
128  void simpleInterpolation(const Img8u *poBayerImg);
129  #ifdef ICL_HAVE_IPP
130  void nnInterpolationIpp(const Img8u *poBayerImg);
131  #endif
132 
133  // Utility functions
134  void clearBorders(icl8u *rgb, int sx, int sy, int w);
135  inline void clip(int *iIn, icl8u *iOut) {
136  *iOut = *iIn = *iIn < 0 ? 0 : *iIn > 255 ? 255 : 0;
137  }
138  };
139 
140  } // namespace core
141 } // namespace icl
142 
undocument this line if you encounter any issues!
Definition: Any.h:37
Class interface for un-copyable classes.
Definition: Uncopyable.h:64
static const Size null
null is w=0, h=0
Definition: Size.h:64
Ipp8u icl8u
8Bit unsigned integer type for the ICL
Definition: BasicTypes.h:64
bayerConverterMethod
Definition: BayerConverter.h:46
ICLQt_API ImgQ rgb(const ImgQ &image)
converts a given image to formatRGB
bayerPattern m_eBayerPattern
Definition: BayerConverter.h:118
bayerPattern
Definition: BayerConverter.h:55
IppiBayerGrid m_IppBayerPattern
Definition: BayerConverter.h:120
std::vector< icl8u > m_buffer
internal buffer;
Definition: BayerConverter.h:115
void setBayerPattern(bayerPattern eBayerPattern)
Definition: BayerConverter.h:79
Definition: BayerConverter.h:57
Definition: BayerConverter.h:49
Definition: BayerConverter.h:48
Size class of the ICL.
Definition: Size.h:61
bayerConverterMethod m_eConvMethod
Definition: BayerConverter.h:117
Definition: BayerConverter.h:58
Definition: BayerConverter.h:51
Utiltity class for bayer pattern conversion.
Definition: BayerConverter.h:43
ImgBase is the Image-Interface class that provides save access to underlying Img-template .
Definition: ImgBase.h:131
void setBayerPattern(const std::string &pattern)
Definition: BayerConverter.h:87
void clip(int *iIn, icl8u *iOut)
Definition: BayerConverter.h:135
#define ICLCore_API
Definition: CompatMacros.h:174
void setMethod(const std::string &method)
Definition: BayerConverter.h:91
void setConverterMethod(bayerConverterMethod eConvMethod)
Definition: BayerConverter.h:83
Definition: BayerConverter.h:50