eLynx SDK
v3.0.1 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 00069 00081 // http://www.reference.com/browse/wiki/Demosaicing 00082 // http://scien.stanford.edu/class/psych221/projects/99/tingchen/main.htm 00083 enum EBayerToColorConversion 00084 { 00085 BCC_Grey, 00086 BCC_Bin2x2, 00087 BCC_Raw, 00088 BCC_Nearest, 00089 00090 BCC_Bilinear, 00091 00092 BCC_MalvarHeCutler, 00093 00094 BCC_Bicubic, 00095 00096 BCC_Cok, 00097 00098 BCC_Freeman, 00099 00100 BCC_Adaptive, 00101 00102 BCC_LarochePrescott, 00103 00104 BCC_Hamilton, 00105 00106 BCC_HamiltonAdams, 00107 00108 BCC_Adams, 00109 00110 BCC_WangLinXue, 00111 00112 BCC_Kimmel, 00113 00114 BCC_LukinKubasov, 00115 00116 BCC_ChuanLin, 00117 00118 BCC_WemmiaoLu, 00119 00120 BCC_PRI, 00121 00122 BCC_PMI, 00123 00124 BCC_VNG, 00125 00126 BCC_AHD, 00127 00128 BCC_ChangTan, 00129 00130 BCC_Max, 00131 BCC_Default = BCC_Adaptive 00132 }; 00133 00134 // -Demosaicing for digital imaging device using perceptually uniform color space 00135 // http://www.patentstorm.us/patents/6809765-fulltext.html 00136 // http://www.13thmonkey.org/~boris/rawtobw/ 00137 // http://www.tortuga.com.au/products/info/wp/ 00138 // http://www.csee.wvu.edu/~xinl/source.html source 00139 // http://www.dei.unipd.it/~menond/pub/dfapd/dfapd.html 00140 // http://people.csail.mit.edu/mtappen/iccv-sctv.pdf 00141 00142 // "Primary-consistent soft-decision color demosaicking for digital cameras" 00143 // X. Wu and N. Zhang Algorithm 00144 // IEEE Trans. Image Processing, vol. 13, pp 1263-1274, Sept. 2004. 00145 00147 enum EBayerToGreyConversion 00148 { 00149 BGC_AsIs, 00150 00151 BGC_Max, 00152 BGC_Default = BGC_AsIs 00153 }; 00154 00155 ExportedByImage const char * elxToString(EBayerMatrix iBayer); 00156 ExportedByImage const char * elxToString(EBayerToGreyConversion iMethod); 00157 ExportedByImage const char * elxToString(EBayerToColorConversion iMethod); 00158 00164 ExportedByImage EBayerMatrix elxGetBayerAt(EBayerMatrix iBayer, uint32 iX, uint32 iY); 00165 ExportedByImage EBayerMatrix elxGetBayerLeft(EBayerMatrix iBayer); 00166 ExportedByImage EBayerMatrix elxGetBayerRight(EBayerMatrix iBayer); 00167 ExportedByImage EBayerMatrix elxGetBayerUp(EBayerMatrix iBayer); 00168 ExportedByImage EBayerMatrix elxGetBayerDown(EBayerMatrix iBayer); 00169 00170 ExportedByImage EBayerMatrix elxFlipHorizontal(EBayerMatrix iBayer, uint32 iWidth); 00171 ExportedByImage EBayerMatrix elxFlipVertical(EBayerMatrix iBayer, uint32 iHeight); 00172 ExportedByImage EBayerMatrix elxFlip(EBayerMatrix iBayer, EFlipPlane iFlipPlane, uint32 iWidth, uint32 iHeight); 00173 00174 ExportedByImage EBayerMatrix elxRotate180(EBayerMatrix iBayer, uint32 iWidth, uint32 iHeight); 00175 ExportedByImage EBayerMatrix elxRotate90Left(EBayerMatrix iBayer, uint32 iWidth); 00176 ExportedByImage EBayerMatrix elxRotate90Right(EBayerMatrix iBayer, uint32 iHeight); 00177 ExportedByImage EBayerMatrix elxRotate(EBayerMatrix iBayer, ERightRotation iRotation, uint32 iWidth, uint32 iHeight); 00178 00179 00180 class ExportedByImage IBayerHandler 00181 { 00182 public: 00184 virtual ~IBayerHandler(); 00185 00186 virtual boost::shared_ptr< AbstractImage > CreateRGB( 00187 const AbstractImage& iImage, 00188 EBayerMatrix iBayer, 00189 EBayerToColorConversion iMethod, 00190 ProgressNotifier& iNotifier=ProgressNotifier_NULL) const=0; 00191 00192 virtual boost::shared_ptr< AbstractImage > CreateBayer( 00193 const AbstractImage& iImage, 00194 EBayerMatrix iBayer, 00195 ProgressNotifier& iNotifier=ProgressNotifier_NULL) const=0; 00196 00197 virtual bool Balance( 00198 AbstractImage& ioImage, EBayerMatrix iBayer, 00199 double iRed, double iGreen, double iBlue, 00200 uint32 iChannelMask) const=0; 00201 00202 virtual bool ComputeMean( 00203 const AbstractImage& iImage, EBayerMatrix iBayer, 00204 double& oMeanR, double& oMeanG, double& oMeanB, 00205 bool ibNormalized=false) const=0; 00206 00207 virtual bool ComputeStandardDeviation( 00208 const AbstractImage& iImage, EBayerMatrix iBayer, 00209 double& oMeanR, double& oMeanG, double& oMeanB, 00210 double& oStdDevR, double& oStdDevG, double& oStdDevB, 00211 bool ibNormalized=false) const=0; 00212 00213 virtual bool Affine( 00214 AbstractImage& ioImage, EBayerMatrix iBayer, 00215 double iScaleR, double iOffsetR, 00216 double iScaleG, double iOffsetG, 00217 double iScaleB, double iOffsetB) const=0; 00218 }; 00219 00220 ExportedByImage const IBayerHandler& elxGetBayerHandler(EPixelFormat iPixelFormat); 00221 ExportedByImage const IBayerHandler& elxGetBayerHandler(const AbstractImage& iImage); 00222 00223 } // namespace Image 00224 } // namespace eLynx 00225 00226 #endif // __Bayer_h__