eLynx SDK
v3.3.0 C++ image processing API reference |
00001 //============================================================================ 00002 // Bayer.h Image.Component package 00003 //============================================================================ 00004 // Usage : Tool for Bayer matrix and demosaicing 00005 //---------------------------------------------------------------------------- 00006 // Copyright (C) 2006 by eLynx project 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 // See the GNU Library General Public License for more details. 00017 //---------------------------------------------------------------------------- 00018 #ifndef __Bayer_h__ 00019 #define __Bayer_h__ 00020 00021 #include <elx/core/CoreTypes.h> 00022 #include "ImageLib.h" 00023 #include "ImageImpl.h" 00024 #include "IImageGeometry.h" 00025 #include "PixelIterator.h" 00026 00027 namespace eLynx { 00028 namespace Image { 00029 00039 // BM_None BM_GRBG BM_RGGB BM_GBRG BM_BGGR 00040 // +-+-+ +-+-+ +-+-+ +-+-+ +-+-+ 00041 // |L|L| |G|R| |R|G| |G|B| |B|G| 00042 // +-+-+ +-+-+ +-+-+ +-+-+ +-+-+ 00043 // |L|L| |B|G| |G|B| |R|G| |G|R| 00044 // +-+-+ +-+-+ +-+-+ +-+-+ +-+-+ 00045 enum EBayerMatrix 00046 { 00047 BM_None, 00048 BM_GRBG, 00049 BM_GBRG, 00050 BM_RGGB, 00051 BM_BGGR 00052 }; 00053 00057 ExportedByImage EBayerMatrix elxToEBayerMatrix(const char * iprType); 00058 00059 //#define USE_LAST_BAYER_METHODS 00060 00087 00088 // http://www.reference.com/browse/wiki/Demosaicing 00089 // http://scien.stanford.edu/class/psych221/projects/99/tingchen/main.htm 00090 // http://www.danielemenon.it/top/demosaicking-list.php 00091 // http://www.ipol.im/pub/algo/bcms_self_similarity_driven_demosaicking/ 00092 // http://www.linuxphoto.org/html/dcb.html 00093 00094 enum EBayerToColorConversion 00095 { 00096 BCC_Grey, 00097 BCC_Bin2x2, 00098 BCC_Raw, 00099 BCC_Nearest, 00100 00101 BCC_Bilinear, 00102 00103 BCC_MalvarHeCutler, 00104 00105 BCC_Bicubic, 00106 00107 BCC_Cok, 00108 00109 BCC_Freeman, 00110 00111 BCC_Adaptive, 00112 00113 BCC_LarochePrescott, 00114 00115 BCC_Hamilton, 00116 00117 BCC_HamiltonAdams, 00118 00119 BCC_Adams, 00120 00121 BCC_WangLinXue, 00122 00123 BCC_Kimmel, 00124 00125 BCC_LukinKubasov, 00126 00127 BCC_ChuanLin, 00128 00129 BCC_WemmiaoLu, 00130 00131 BCC_PRI, 00132 00133 BCC_PMI, 00134 00135 BCC_VNG, 00136 00137 BCC_AHD, 00138 00139 BCC_ChangTan, 00140 00141 00142 #ifdef USE_LAST_BAYER_METHODS 00143 BCC_AWD, 00144 00145 BCC_LCH, 00146 00147 BCC_RACC, 00148 00149 #endif 00150 BCC_Max, 00151 BCC_Default = BCC_Adaptive 00152 }; 00153 00154 // -Demosaicing for digital imaging device using perceptually uniform color space 00155 // http://www.patentstorm.us/patents/6809765-fulltext.html 00156 // http://www.13thmonkey.org/~boris/rawtobw/ 00157 // http://www.tortuga.com.au/products/info/wp/ 00158 // http://www.csee.wvu.edu/~xinl/source.html source 00159 // http://www.dei.unipd.it/~menond/pub/dfapd/dfapd.html 00160 // http://people.csail.mit.edu/mtappen/iccv-sctv.pdf 00161 00162 // "Primary-consistent soft-decision color demosaicking for digital cameras" 00163 // X. Wu and N. Zhang Algorithm 00164 // IEEE Trans. Image Processing, vol. 13, pp 1263-1274, Sept. 2004. 00165 00167 enum EBayerToGreyConversion 00168 { 00169 BGC_AsIs, 00170 00171 BGC_Max, 00172 BGC_Default = BGC_AsIs 00173 }; 00174 00175 ExportedByImage const char * elxToString(EBayerMatrix iBayer); 00176 ExportedByImage const char * elxToString(EBayerToGreyConversion iMethod); 00177 ExportedByImage const char * elxToString(EBayerToColorConversion iMethod); 00178 00184 ExportedByImage EBayerMatrix elxGetBayerAt(EBayerMatrix iBayer, uint32 iX, uint32 iY); 00185 ExportedByImage EBayerMatrix elxGetBayerLeft(EBayerMatrix iBayer); 00186 ExportedByImage EBayerMatrix elxGetBayerRight(EBayerMatrix iBayer); 00187 ExportedByImage EBayerMatrix elxGetBayerUp(EBayerMatrix iBayer); 00188 ExportedByImage EBayerMatrix elxGetBayerDown(EBayerMatrix iBayer); 00189 00190 ExportedByImage EBayerMatrix elxFlipHorizontal(EBayerMatrix iBayer, uint32 iWidth); 00191 ExportedByImage EBayerMatrix elxFlipVertical(EBayerMatrix iBayer, uint32 iHeight); 00192 ExportedByImage EBayerMatrix elxFlip(EBayerMatrix iBayer, EFlipPlane iFlipPlane, uint32 iWidth, uint32 iHeight); 00193 00194 ExportedByImage EBayerMatrix elxRotate180(EBayerMatrix iBayer, uint32 iWidth, uint32 iHeight); 00195 ExportedByImage EBayerMatrix elxRotate90Left(EBayerMatrix iBayer, uint32 iWidth); 00196 ExportedByImage EBayerMatrix elxRotate90Right(EBayerMatrix iBayer, uint32 iHeight); 00197 ExportedByImage EBayerMatrix elxRotate(EBayerMatrix iBayer, ERightRotation iRotation, uint32 iWidth, uint32 iHeight); 00198 00199 00200 class ExportedByImage IBayerHandler 00201 { 00202 public: 00204 virtual ~IBayerHandler(); 00205 00206 virtual boost::shared_ptr< AbstractImage > CreateRGB( 00207 const AbstractImage& iImage, 00208 EBayerMatrix iBayer, 00209 EBayerToColorConversion iMethod, 00210 ProgressNotifier& iNotifier=ProgressNotifier_NULL) const=0; 00211 00212 virtual boost::shared_ptr< AbstractImage > CreateBayer( 00213 const AbstractImage& iImage, 00214 EBayerMatrix iBayer, 00215 ProgressNotifier& iNotifier=ProgressNotifier_NULL) const=0; 00216 00217 virtual bool Balance( 00218 AbstractImage& ioImage, EBayerMatrix iBayer, 00219 double iRed, double iGreen, double iBlue) const=0; 00220 00221 virtual bool ComputeMean( 00222 const AbstractImage& iImage, EBayerMatrix iBayer, 00223 double& oMeanR, double& oMeanG, double& oMeanB, 00224 bool ibNormalized=false) const=0; 00225 00226 virtual bool ComputeStandardDeviation( 00227 const AbstractImage& iImage, EBayerMatrix iBayer, 00228 double& oMeanR, double& oMeanG, double& oMeanB, 00229 double& oStdDevR, double& oStdDevG, double& oStdDevB, 00230 bool ibNormalized=false) const=0; 00231 00232 virtual bool Affine( 00233 AbstractImage& ioImage, EBayerMatrix iBayer, 00234 double iScaleR, double iOffsetR, 00235 double iScaleG, double iOffsetG, 00236 double iScaleB, double iOffsetB) const=0; 00237 }; 00238 00239 ExportedByImage const IBayerHandler& elxGetBayerHandler(EPixelFormat iPixelFormat); 00240 ExportedByImage const IBayerHandler& elxGetBayerHandler(const AbstractImage& iImage); 00241 00242 } // namespace Image 00243 } // namespace eLynx 00244 00245 #endif // __Bayer_h__