eLynx SDK
v3.0.1 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 #define elxUSE_ImageHLS 00031 #define elxUSE_ImageLab 00032 00033 // minimize generated size code 00034 //#define elxUSE_ImageComplex 00035 //#define elxUSE_ImageXYZ 00036 //#define elxUSE_ImageLuv 00037 //#define elxUSE_ImageLch 00038 //#define elxUSE_ImageHLab 00039 00040 namespace eLynx { 00041 namespace Image { 00042 00046 template <class Pixel> 00047 class ExportedByImage ImageImpl : public AbstractImage 00048 { 00049 public: 00050 typedef Pixel Pixel_t; 00051 00054 00057 explicit ImageImpl(); 00058 00063 explicit ImageImpl(uint32 iWidth, uint32 iHeight); 00064 00069 explicit ImageImpl(uint32 iWidth, uint32 iHeight, const Pixel& iPixel); 00070 00073 ImageImpl(const ImageImpl& iImage); 00074 00078 const ImageImpl& operator = (const ImageImpl& iImage); 00080 00081 00084 virtual EPixelFormat GetPixelFormat() const; 00085 virtual bool IsValid() const; 00086 virtual boost::shared_ptr<IPixelIterator> Begin(); 00087 virtual boost::shared_ptr<IPixelIterator> Begin() const; 00088 virtual boost::shared_ptr<IPixelIterator> End(); 00089 virtual boost::shared_ptr<IPixelIterator> End() const; 00091 00092 00095 00100 const Pixel_t * GetPixel(uint32 iX=0, uint32 iY=0) const; 00101 00106 Pixel_t * GetPixel(uint32 iX=0, uint32 iY=0); 00107 00110 const Pixel_t * GetPixelEnd() const; 00111 00114 Pixel_t * GetPixelEnd(); 00115 00118 const typename Pixel::type * GetSamples() const; 00119 00122 typename Pixel::type * GetSamples(); 00123 00126 const typename Pixel::type * GetSamplesEnd() const; 00127 00130 typename Pixel::type * GetSamplesEnd(); 00131 00134 static Pixel_t Null(); 00135 static Pixel_t White(); 00136 static Pixel_t Black(); 00138 00144 bool CopyAndForget(boost::shared_ptr<ImageImpl<Pixel> >& iospImage); 00145 00148 uint32 sizeofWidth() const; 00149 00152 uint32 sizeofMap() const; 00153 00154 protected: 00157 boost::scoped_array<Pixel_t> _spMap; 00158 }; 00159 00160 00163 00164 // declare all suitable image types. 00165 typedef ImageImpl< PixelLub > ImageLub; 00166 typedef ImageImpl< PixelLus > ImageLus; 00167 typedef ImageImpl< PixelLi > ImageLi; 00168 typedef ImageImpl< PixelLl > ImageLl; 00169 typedef ImageImpl< PixelLf > ImageLf; 00170 typedef ImageImpl< PixelLd > ImageLd; 00171 00172 typedef ImageImpl< PixelLAub > ImageLAub; 00173 typedef ImageImpl< PixelLAus > ImageLAus; 00174 typedef ImageImpl< PixelLAi > ImageLAi; 00175 typedef ImageImpl< PixelLAl > ImageLAl; 00176 typedef ImageImpl< PixelLAf > ImageLAf; 00177 typedef ImageImpl< PixelLAd > ImageLAd; 00178 00179 typedef ImageImpl< PixelRGBub > ImageRGBub; 00180 typedef ImageImpl< PixelRGBus > ImageRGBus; 00181 typedef ImageImpl< PixelRGBi > ImageRGBi; 00182 typedef ImageImpl< PixelRGBl > ImageRGBl; 00183 typedef ImageImpl< PixelRGBf > ImageRGBf; 00184 typedef ImageImpl< PixelRGBd > ImageRGBd; 00185 00186 typedef ImageImpl< PixelRGBAub > ImageRGBAub; 00187 typedef ImageImpl< PixelRGBAus > ImageRGBAus; 00188 typedef ImageImpl< PixelRGBAi > ImageRGBAi; 00189 typedef ImageImpl< PixelRGBAl > ImageRGBAl; 00190 typedef ImageImpl< PixelRGBAf > ImageRGBAf; 00191 typedef ImageImpl< PixelRGBAd > ImageRGBAd; 00192 00193 #ifdef elxUSE_ImageComplex 00194 typedef ImageImpl< PixelComplexi > ImageComplexi; 00195 typedef ImageImpl< PixelComplexf > ImageComplexf; 00196 typedef ImageImpl< PixelComplexd > ImageComplexd; 00197 #endif 00198 00199 #ifdef elxUSE_ImageHLS 00200 typedef ImageImpl< PixelHLSf > ImageHLSf; 00201 typedef ImageImpl< PixelHLSd > ImageHLSd; 00202 #endif 00203 00204 #ifdef elxUSE_ImageXYZ 00205 typedef ImageImpl< PixelXYZf > ImageXYZf; 00206 typedef ImageImpl< PixelXYZd > ImageXYZd; 00207 #endif 00208 00209 #ifdef elxUSE_ImageLuv 00210 typedef ImageImpl< PixelLuvf > ImageLuvf; 00211 typedef ImageImpl< PixelLuvd > ImageLuvd; 00212 #endif 00213 00214 #ifdef elxUSE_ImageLab 00215 typedef ImageImpl< PixelLabf > ImageLabf; 00216 typedef ImageImpl< PixelLabd > ImageLabd; 00217 #endif 00218 00219 #ifdef elxUSE_ImageLch 00220 typedef ImageImpl< PixelLchf > ImageLchf; 00221 typedef ImageImpl< PixelLchd > ImageLchd; 00222 #endif 00223 00224 #ifdef elxUSE_ImageHLab 00225 typedef ImageImpl< PixelHLabf > ImageHLabf; 00226 typedef ImageImpl< PixelHLabd > ImageHLabd; 00227 #endif 00228 00234 ExportedByImage bool elxIsImageFormat(EPixelFormat iFormat); 00235 00237 00242 template <class Pixel> 00243 const ImageImpl<Pixel>& elxDowncast(const AbstractImage& iImage); 00244 00249 template <class Pixel> 00250 ImageImpl<Pixel>& elxDowncast(AbstractImage& iImage); 00251 00252 } // namespace Image 00253 } // namespace eLynx 00254 00255 #include "inl/ImageImpl.inl" 00256 00257 #define elxINSTANTIATE_CLASS_FOR_DEFAULT_IMAGE_TYPES(Name) \ 00258 template class Name<PixelLub>; \ 00259 template class Name<PixelLus>; \ 00260 template class Name<PixelLi>; \ 00261 template class Name<PixelLf>; \ 00262 template class Name<PixelLd>; \ 00263 \ 00264 template class Name<PixelLAub>; \ 00265 template class Name<PixelLAus>; \ 00266 template class Name<PixelLAi>; \ 00267 template class Name<PixelLAf>; \ 00268 template class Name<PixelLAd>; \ 00269 \ 00270 template class Name<PixelRGBub>; \ 00271 template class Name<PixelRGBus>; \ 00272 template class Name<PixelRGBi>; \ 00273 template class Name<PixelRGBf>; \ 00274 template class Name<PixelRGBd>; \ 00275 \ 00276 template class Name<PixelRGBAub>; \ 00277 template class Name<PixelRGBAus>; \ 00278 template class Name<PixelRGBAi>; \ 00279 template class Name<PixelRGBAf>; \ 00280 template class Name<PixelRGBAd>; 00281 00282 00283 #ifdef elxUSE_ImageComplex 00284 # define elxINSTANTIATE_CLASS_FOR_IMAGE_COMPLEX(Name) \ 00285 template class Name<PixelComplexi>; \ 00286 template class Name<PixelComplexf>; \ 00287 template class Name<PixelComplexd>; 00288 #else 00289 # define elxINSTANTIATE_CLASS_FOR_IMAGE_COMPLEX(Name) 00290 #endif 00291 00292 #ifdef elxUSE_ImageHLS 00293 # define elxINSTANTIATE_CLASS_FOR_IMAGE_HLS(Name) \ 00294 template class Name<PixelHLSf>; \ 00295 template class Name<PixelHLSd>; 00296 #else 00297 # define elxINSTANTIATE_CLASS_FOR_IMAGE_HLS(Name) 00298 #endif 00299 00300 #ifdef elxUSE_ImageXYZ 00301 # define elxINSTANTIATE_CLASS_FOR_IMAGE_XYZ(Name) \ 00302 template class Name<PixelXYZf>; \ 00303 template class Name<PixelXYZd>; 00304 #else 00305 # define elxINSTANTIATE_CLASS_FOR_IMAGE_XYZ(Name) 00306 #endif 00307 00308 #ifdef elxUSE_ImageLuv 00309 # define elxINSTANTIATE_CLASS_FOR_IMAGE_LUV(Name) \ 00310 template class Name<PixelLuvf>; \ 00311 template class Name<PixelLuvd>; 00312 #else 00313 # define elxINSTANTIATE_CLASS_FOR_IMAGE_LUV(Name) 00314 #endif 00315 00316 #ifdef elxUSE_ImageLab 00317 # define elxINSTANTIATE_CLASS_FOR_IMAGE_LAB(Name) \ 00318 template class Name<PixelLabf>; \ 00319 template class Name<PixelLabd>; 00320 #else 00321 # define elxINSTANTIATE_CLASS_FOR_IMAGE_LAB(Name) 00322 #endif 00323 00324 #ifdef elxUSE_ImageLch 00325 # define elxINSTANTIATE_CLASS_FOR_IMAGE_LCH(Name) \ 00326 template class Name<PixelLchf>; \ 00327 template class Name<PixelLchd>; 00328 #else 00329 # define elxINSTANTIATE_CLASS_FOR_IMAGE_LCH(Name) 00330 #endif 00331 00332 #ifdef elxUSE_ImageHLab 00333 # define elxINSTANTIATE_CLASS_FOR_IMAGE_HLAB(Name) \ 00334 template class Name<PixelHLabf>; \ 00335 template class Name<PixelHLabd>; 00336 #else 00337 # define elxINSTANTIATE_CLASS_FOR_IMAGE_HLAB(Name) 00338 #endif 00339 00340 00341 #define elxINSTANTIATE_CLASS_FOR_ALL_IMAGE_TYPES(Name) \ 00342 elxINSTANTIATE_CLASS_FOR_DEFAULT_IMAGE_TYPES(Name) \ 00343 elxINSTANTIATE_CLASS_FOR_IMAGE_COMPLEX(Name) \ 00344 elxINSTANTIATE_CLASS_FOR_IMAGE_HLS(Name) \ 00345 elxINSTANTIATE_CLASS_FOR_IMAGE_XYZ(Name) \ 00346 elxINSTANTIATE_CLASS_FOR_IMAGE_LUV(Name) \ 00347 elxINSTANTIATE_CLASS_FOR_IMAGE_LAB(Name) \ 00348 elxINSTANTIATE_CLASS_FOR_IMAGE_LCH(Name) \ 00349 elxINSTANTIATE_CLASS_FOR_IMAGE_HLAB(Name) 00350 00351 #endif // __ImageImpl_h__