eLynx SDK
v3.3.0 C++ image processing API reference |
00001 //============================================================================ 00002 // ImageImpl.h Image.Component package 00003 //============================================================================ 00004 // Usage : define image implementation class, 00005 // image class with specialized pixel type. 00006 //---------------------------------------------------------------------------- 00007 // Inheritance : 00008 // ImageImpl<Pixel> 00009 // +AbstractImage 00010 //---------------------------------------------------------------------------- 00011 // Copyright (C) 2006 by eLynx project 00012 // 00013 // This library is free software; you can redistribute it and/or 00014 // modify it under the terms of the GNU Library General Public 00015 // License as published by the Free Software Foundation; either 00016 // version 2 of the License, or (at your option) any later version. 00017 // 00018 // This library is distributed in the hope that it will be useful, 00019 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00021 // See the GNU Library General Public License for more details. 00022 //---------------------------------------------------------------------------- 00023 #ifndef __ImageImpl_h__ 00024 #define __ImageImpl_h__ 00025 00026 #include "AbstractImage.h" 00027 #include <boost/scoped_array.hpp> 00028 #include <boost/shared_ptr.hpp> 00029 00030 // minimize generated size code 00031 #define elxUSE_ImageHLS 00032 #define elxUSE_ImageLab 00033 #define elxUSE_ImageComplex 00034 //#define elxUSE_ImageXYZ 00035 //#define elxUSE_ImageLuv 00036 //#define elxUSE_ImageLch 00037 //#define elxUSE_ImageHLab 00038 00039 namespace eLynx { 00040 namespace Image { 00041 00045 template <class Pixel> 00046 class ExportedByImage ImageImpl : public AbstractImage 00047 { 00048 public: 00051 00054 explicit ImageImpl(); 00055 00060 explicit ImageImpl(uint32 iWidth, uint32 iHeight); 00061 00066 explicit ImageImpl(uint32 iWidth, uint32 iHeight, const Pixel& iPixel); 00067 00070 ImageImpl(const ImageImpl& iImage); 00071 00075 const ImageImpl& operator = (const ImageImpl& iImage); 00077 00078 00081 virtual EPixelFormat GetPixelFormat() const; 00082 virtual bool IsValid() const; 00083 virtual boost::shared_ptr<IPixelIterator> Begin(); 00084 virtual boost::shared_ptr<IPixelIterator> Begin() const; 00085 virtual boost::shared_ptr<IPixelIterator> End(); 00086 virtual boost::shared_ptr<IPixelIterator> End() const; 00088 00089 00092 00097 const Pixel * GetPixel(uint32 iX=0, uint32 iY=0) const; 00098 00103 Pixel * GetPixel(uint32 iX=0, uint32 iY=0); 00104 00107 const Pixel * GetPixelEnd() const; 00108 00111 Pixel * GetPixelEnd(); 00112 00115 const typename Pixel::type * GetSamples() const; 00116 00119 typename Pixel::type * GetSamples(); 00120 00123 const typename Pixel::type * GetSamplesEnd() const; 00124 00127 typename Pixel::type * GetSamplesEnd(); 00128 00131 static Pixel Null(); 00132 static Pixel White(); 00133 static Pixel Black(); 00135 00141 bool CopyAndForget(boost::shared_ptr<ImageImpl<Pixel> >& iospImage); 00142 00145 uint32 sizeofWidth() const; 00146 00149 uint32 sizeofMap() const; 00150 00151 protected: 00154 boost::scoped_array<Pixel> _spMap; 00155 }; 00156 00157 00160 00161 // declare all suitable image types. 00162 typedef ImageImpl< PixelLub > ImageLub; 00163 typedef ImageImpl< PixelLus > ImageLus; 00164 typedef ImageImpl< PixelLi > ImageLi; 00165 typedef ImageImpl< PixelLl > ImageLl; 00166 typedef ImageImpl< PixelLf > ImageLf; 00167 typedef ImageImpl< PixelLd > ImageLd; 00168 00169 typedef ImageImpl< PixelLAub > ImageLAub; 00170 typedef ImageImpl< PixelLAus > ImageLAus; 00171 typedef ImageImpl< PixelLAi > ImageLAi; 00172 typedef ImageImpl< PixelLAl > ImageLAl; 00173 typedef ImageImpl< PixelLAf > ImageLAf; 00174 typedef ImageImpl< PixelLAd > ImageLAd; 00175 00176 typedef ImageImpl< PixelRGBub > ImageRGBub; 00177 typedef ImageImpl< PixelRGBus > ImageRGBus; 00178 typedef ImageImpl< PixelRGBi > ImageRGBi; 00179 typedef ImageImpl< PixelRGBl > ImageRGBl; 00180 typedef ImageImpl< PixelRGBf > ImageRGBf; 00181 typedef ImageImpl< PixelRGBd > ImageRGBd; 00182 00183 typedef ImageImpl< PixelRGBAub > ImageRGBAub; 00184 typedef ImageImpl< PixelRGBAus > ImageRGBAus; 00185 typedef ImageImpl< PixelRGBAi > ImageRGBAi; 00186 typedef ImageImpl< PixelRGBAl > ImageRGBAl; 00187 typedef ImageImpl< PixelRGBAf > ImageRGBAf; 00188 typedef ImageImpl< PixelRGBAd > ImageRGBAd; 00189 00190 #ifdef elxUSE_ImageComplex 00191 typedef ImageImpl< PixelComplexi > ImageComplexi; 00192 typedef ImageImpl< PixelComplexf > ImageComplexf; 00193 typedef ImageImpl< PixelComplexd > ImageComplexd; 00194 #endif 00195 00196 #ifdef elxUSE_ImageHLS 00197 typedef ImageImpl< PixelHLSf > ImageHLSf; 00198 typedef ImageImpl< PixelHLSd > ImageHLSd; 00199 #endif 00200 00201 #ifdef elxUSE_ImageXYZ 00202 typedef ImageImpl< PixelXYZf > ImageXYZf; 00203 typedef ImageImpl< PixelXYZd > ImageXYZd; 00204 #endif 00205 00206 #ifdef elxUSE_ImageLuv 00207 typedef ImageImpl< PixelLuvf > ImageLuvf; 00208 typedef ImageImpl< PixelLuvd > ImageLuvd; 00209 #endif 00210 00211 #ifdef elxUSE_ImageLab 00212 typedef ImageImpl< PixelLabf > ImageLabf; 00213 typedef ImageImpl< PixelLabd > ImageLabd; 00214 #endif 00215 00216 #ifdef elxUSE_ImageLch 00217 typedef ImageImpl< PixelLchf > ImageLchf; 00218 typedef ImageImpl< PixelLchd > ImageLchd; 00219 #endif 00220 00221 #ifdef elxUSE_ImageHLab 00222 typedef ImageImpl< PixelHLabf > ImageHLabf; 00223 typedef ImageImpl< PixelHLabd > ImageHLabd; 00224 #endif 00225 00231 ExportedByImage bool elxIsImageFormat(EPixelFormat iFormat); 00232 00238 ExportedByImage bool elxIsImageColorSpace(EColorSpace iColorSpace); 00240 00245 template <class Pixel> 00246 const ImageImpl<Pixel>& elxDowncast(const AbstractImage& iImage); 00247 00252 template <class Pixel> 00253 ImageImpl<Pixel>& elxDowncast(AbstractImage& iImage); 00254 00255 } // namespace Image 00256 } // namespace eLynx 00257 00258 #include "inl/ImageImpl.inl" 00259 00260 #define elxINSTANTIATE_CLASS_FOR_DEFAULT_IMAGE_TYPES(Name) \ 00261 template class Name<PixelLub>; \ 00262 template class Name<PixelLus>; \ 00263 template class Name<PixelLi>; \ 00264 template class Name<PixelLf>; \ 00265 template class Name<PixelLd>; \ 00266 \ 00267 template class Name<PixelLAub>; \ 00268 template class Name<PixelLAus>; \ 00269 template class Name<PixelLAi>; \ 00270 template class Name<PixelLAf>; \ 00271 template class Name<PixelLAd>; \ 00272 \ 00273 template class Name<PixelRGBub>; \ 00274 template class Name<PixelRGBus>; \ 00275 template class Name<PixelRGBi>; \ 00276 template class Name<PixelRGBf>; \ 00277 template class Name<PixelRGBd>; \ 00278 \ 00279 template class Name<PixelRGBAub>; \ 00280 template class Name<PixelRGBAus>; \ 00281 template class Name<PixelRGBAi>; \ 00282 template class Name<PixelRGBAf>; \ 00283 template class Name<PixelRGBAd>; 00284 00285 00286 #ifdef elxUSE_ImageComplex 00287 # define elxINSTANTIATE_CLASS_FOR_IMAGE_COMPLEX(Name) \ 00288 template class Name<PixelComplexi>; \ 00289 template class Name<PixelComplexf>; \ 00290 template class Name<PixelComplexd>; 00291 #else 00292 # define elxINSTANTIATE_CLASS_FOR_IMAGE_COMPLEX(Name) 00293 #endif 00294 00295 #ifdef elxUSE_ImageHLS 00296 # define elxINSTANTIATE_CLASS_FOR_IMAGE_HLS(Name) \ 00297 template class Name<PixelHLSf>; \ 00298 template class Name<PixelHLSd>; 00299 #else 00300 # define elxINSTANTIATE_CLASS_FOR_IMAGE_HLS(Name) 00301 #endif 00302 00303 #ifdef elxUSE_ImageXYZ 00304 # define elxINSTANTIATE_CLASS_FOR_IMAGE_XYZ(Name) \ 00305 template class Name<PixelXYZf>; \ 00306 template class Name<PixelXYZd>; 00307 #else 00308 # define elxINSTANTIATE_CLASS_FOR_IMAGE_XYZ(Name) 00309 #endif 00310 00311 #ifdef elxUSE_ImageLuv 00312 # define elxINSTANTIATE_CLASS_FOR_IMAGE_LUV(Name) \ 00313 template class Name<PixelLuvf>; \ 00314 template class Name<PixelLuvd>; 00315 #else 00316 # define elxINSTANTIATE_CLASS_FOR_IMAGE_LUV(Name) 00317 #endif 00318 00319 #ifdef elxUSE_ImageLab 00320 # define elxINSTANTIATE_CLASS_FOR_IMAGE_LAB(Name) \ 00321 template class Name<PixelLabf>; \ 00322 template class Name<PixelLabd>; 00323 #else 00324 # define elxINSTANTIATE_CLASS_FOR_IMAGE_LAB(Name) 00325 #endif 00326 00327 #ifdef elxUSE_ImageLch 00328 # define elxINSTANTIATE_CLASS_FOR_IMAGE_LCH(Name) \ 00329 template class Name<PixelLchf>; \ 00330 template class Name<PixelLchd>; 00331 #else 00332 # define elxINSTANTIATE_CLASS_FOR_IMAGE_LCH(Name) 00333 #endif 00334 00335 #ifdef elxUSE_ImageHLab 00336 # define elxINSTANTIATE_CLASS_FOR_IMAGE_HLAB(Name) \ 00337 template class Name<PixelHLabf>; \ 00338 template class Name<PixelHLabd>; 00339 #else 00340 # define elxINSTANTIATE_CLASS_FOR_IMAGE_HLAB(Name) 00341 #endif 00342 00343 00344 #define elxINSTANTIATE_CLASS_FOR_ALL_IMAGE_TYPES(Name) \ 00345 elxINSTANTIATE_CLASS_FOR_DEFAULT_IMAGE_TYPES(Name) \ 00346 elxINSTANTIATE_CLASS_FOR_IMAGE_COMPLEX(Name) \ 00347 elxINSTANTIATE_CLASS_FOR_IMAGE_HLS(Name) \ 00348 elxINSTANTIATE_CLASS_FOR_IMAGE_XYZ(Name) \ 00349 elxINSTANTIATE_CLASS_FOR_IMAGE_LUV(Name) \ 00350 elxINSTANTIATE_CLASS_FOR_IMAGE_LAB(Name) \ 00351 elxINSTANTIATE_CLASS_FOR_IMAGE_LCH(Name) \ 00352 elxINSTANTIATE_CLASS_FOR_IMAGE_HLAB(Name) 00353 00354 #endif // __ImageImpl_h__