00001 #ifndef Impala_Core_Array_GaussDerivative_h
00002 #define Impala_Core_Array_GaussDerivative_h
00003
00004 #include "Core/Array/MakeGaussian1d.h"
00005 #include "Core/Array/ConvKernelSeparated.h"
00006 #include "Core/Array/Set.h"
00007 #ifdef CUDA
00008 #include "Link/Cuda/Cuda.h"
00009 #include "Link/Cuda/GaussDerivative.h"
00010 #endif
00011
00012 namespace Impala
00013 {
00014 namespace Core
00015 {
00016 namespace Array
00017 {
00018
00019
00020 template<class DstArrayT, class SrcArrayT>
00021 inline void
00022 GaussDerivative(DstArrayT*& dst, SrcArrayT* src, double sigma,
00023 int orderDerivx, int orderDerivy, double truncation)
00024 {
00025 #ifdef CUDA
00026 if(Link::Cuda::CudaUsed())
00027 {
00028 bool result = Link::Cuda::GaussDerivative(dst, src, sigma, orderDerivx,
00029 orderDerivy, truncation);
00030 if(result) return;
00031 }
00032 #endif
00033
00034 GaussDerivative(dst, src, sigma, sigma, orderDerivx, orderDerivy,
00035 truncation);
00036 }
00037
00038
00039 template<class DstArrayT, class SrcArrayT>
00040 inline void
00041 GaussDerivative(DstArrayT*& dst, SrcArrayT* src, double sx, double sy,
00042 int orderDerivx, int orderDerivy, double truncation)
00043 {
00044 Array2dScalarReal64* gx = MakeGaussian1d(sx, orderDerivx, truncation,
00045 src->CW());
00046 Array2dScalarReal64* gy = MakeGaussian1d(sy, orderDerivy, truncation,
00047 src->CH());
00048 ConvKernelSeparated(dst, src, gx, gy);
00049 delete gx;
00050 delete gy;
00051 }
00052
00053
00054 template<class DstArrayT, class SrcArrayT>
00055 inline void
00056 GaussDerivativeVec3(DstArrayT*& dst, SrcArrayT* src, double sigma,
00057 int orderDerivx, int orderDerivy, double truncation)
00058 {
00059 Array2dScalarReal64* gx = MakeGaussian1d(sigma, orderDerivx, truncation,
00060 src->CW());
00061 Array2dScalarReal64* gy = MakeGaussian1d(sigma, orderDerivy, truncation,
00062 src->CH());
00063 Array2dVec3Real64* gxV = 0;
00064 Set(gxV, gx);
00065 Array2dVec3Real64* gyV = 0;
00066 Set(gyV, gy);
00067 ConvKernelSeparated(dst, src, gxV, gyV);
00068 delete gx;
00069 delete gy;
00070 delete gxV;
00071 delete gyV;
00072 }
00073
00074 }
00075 }
00076 }
00077
00078 #endif