eLynx SDK
v3.0.1 C++ image processing API reference |
00001 //============================================================================ 00002 // ConvolutionKernel.h Math.Component package 00003 //============================================================================ 00004 // Usage : definition of convolution kernel as a simple W x H 00005 // float or double matrix. 00006 //---------------------------------------------------------------------------- 00007 // Copyright (C) 2006 by eLynx project 00008 // 00009 // This library is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU Library General Public 00011 // License as published by the Free Software Foundation; either 00012 // version 2 of the License, or (at your option) any later version. 00013 // 00014 // This library is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00017 // See the GNU Library General Public License for more details. 00018 //---------------------------------------------------------------------------- 00019 #ifndef __ConvolutionKernel_h__ 00020 #define __ConvolutionKernel_h__ 00021 00022 #include <elx/core/CoreTypes.h> 00023 #include <boost/shared_array.hpp> 00024 00025 namespace eLynx { 00026 namespace Math { 00027 00032 enum ECompassDirection 00033 { 00034 CD_North = 0, 00035 CD_NorthEast, 00036 CD_East, 00037 CD_SouthEast, 00038 CD_South, 00039 CD_SouthWest, 00040 CD_West, 00041 CD_NorthWest 00042 }; 00043 00046 template<typename T> 00047 struct ConvolutionKernel 00048 { 00049 typedef T type; 00050 00053 ConvolutionKernel(); 00054 00059 ConvolutionKernel(uint32 iWidth, uint32 iHeight, T iV = T(1)); 00060 00065 ConvolutionKernel(uint32 iWidth, uint32 iHeight, const T * iprArray); 00066 00069 ConvolutionKernel(const ConvolutionKernel& iOther); 00070 00073 template<typename U> 00074 ConvolutionKernel(const ConvolutionKernel<U>& iOther); 00075 00078 ConvolutionKernel& operator=(const ConvolutionKernel& iOther); 00079 00082 template<typename U> 00083 ConvolutionKernel& operator=(const ConvolutionKernel<U>& iOther); 00084 00087 uint32 GetSize() const; 00088 00091 uint32 GetWidth() const; 00092 00095 uint32 GetHeight() const; 00096 00099 T GetSum() const; 00100 00102 void Normalize(); 00103 00107 ConvolutionKernel Rotated(const ECompassDirection iDirection) const; 00108 00110 bool IsValid() const; 00111 00112 00115 bool IsHorizontal() const; 00116 00119 bool IsVertical() const; 00120 00123 bool IsSquare() const; 00124 00127 bool Is3x3() const; 00128 00131 bool Is5x5() const; 00132 00133 private: 00134 uint32 _Width, _Height; 00135 public: 00136 boost::shared_array<T> _spK; 00137 }; 00138 00139 typedef ConvolutionKernel<float> ConvolutionKernelf; 00140 typedef ConvolutionKernel<double> ConvolutionKerneld; 00141 typedef ConvolutionKernel<int32> ConvolutionKerneli; 00142 00143 } // namespace Math 00144 } // namespace eLynx 00145 00146 #include "inl/ConvolutionKernel.inl" 00147 00148 #endif // __ConvolutionKernel_h__