eLynx SDK
v3.3.0 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 { 00051 ConvolutionKernel(); 00052 00057 ConvolutionKernel(uint32 iWidth, uint32 iHeight, T iV = T(1)); 00058 00063 ConvolutionKernel(uint32 iWidth, uint32 iHeight, const T * iprArray); 00064 00067 ConvolutionKernel(const ConvolutionKernel& iOther); 00068 00071 template<typename U> 00072 ConvolutionKernel(const ConvolutionKernel<U>& iOther); 00073 00076 ConvolutionKernel& operator=(const ConvolutionKernel& iOther); 00077 00080 template<typename U> 00081 ConvolutionKernel& operator=(const ConvolutionKernel<U>& iOther); 00082 00085 uint32 GetSize() const; 00086 00089 uint32 GetWidth() const; 00090 00093 uint32 GetHeight() const; 00094 00097 T GetSum() const; 00098 00100 void Normalize(); 00101 00105 ConvolutionKernel Rotated(const ECompassDirection iDirection) const; 00106 00108 bool IsValid() const; 00109 00112 bool IsHorizontal() const; 00113 00116 bool IsVertical() const; 00117 00120 bool IsSquare() const; 00121 00124 bool Is3x3() const; 00125 00128 bool Is5x5() const; 00129 00130 private: 00131 uint32 _width, _height; 00132 public: 00133 boost::shared_array<T> _spK; 00134 }; 00135 00137 typedef ConvolutionKernel<int32> ConvolutionKerneli; 00138 00140 typedef ConvolutionKernel<float> ConvolutionKernelf; 00141 00143 typedef ConvolutionKernel<double> ConvolutionKerneld; 00144 00145 00146 } // namespace Math 00147 } // namespace eLynx 00148 00149 #include "inl/ConvolutionKernel.inl" 00150 00151 #endif // __ConvolutionKernel_h__