00001 #ifndef Impala_Core_Array_RecGauss_h
00002 #define Impala_Core_Array_RecGauss_h
00003
00004 #include "Core/Array/MakeGaussIIR1d.h"
00005 #include "Core/Array/RecConvKernelSeparated.h"
00006 #include "Core/Array/ConvKernel1d.h"
00007 #include "Core/Array/ConvKernelSeparated.h"
00008 #include "Core/Array/MakeFromData.h"
00009
00010 namespace Impala
00011 {
00012 namespace Core
00013 {
00014 namespace Array
00015 {
00016
00017
00018 template<class DstArrayT, class SrcArrayT>
00019 inline void
00020 RecGauss(DstArrayT*& dst, SrcArrayT* src, double sx, double sy, int dx, int dy,
00021 int recurOrder)
00022 {
00023 bool hasDer = ((dx != 0) || (dy != 0));
00024 DstArrayT* tmp = 0;
00025
00026 Array2dScalarReal64* gx = MakeGaussIIR1d(sx, dx, recurOrder);
00027 Array2dScalarReal64* gy = MakeGaussIIR1d(sy, dy, recurOrder);
00028 if (hasDer)
00029 RecConvKernelSeparated(tmp, src, gx, gy);
00030 else
00031 RecConvKernelSeparated(dst, src, gx, gy);
00032 delete gx;
00033 delete gy;
00034
00035 if (!hasDer)
00036 return;
00037
00038 double d1[3] = {-0.5, 0, 0.5};
00039 double d2[3] = {1, -2, 1};
00040 Array2dScalarReal64* kerx = 0;
00041 Array2dScalarReal64* kery = 0;
00042
00043 if (dx == 1)
00044 kerx = MakeFromData<Array2dScalarReal64>(d1, 3, 1, 0, 0, true);
00045
00046 if (dx == 2)
00047 kerx = MakeFromData<Array2dScalarReal64>(d2, 3, 1, 0, 0, true);
00048
00049 if (dy == 1)
00050 kery = MakeFromData<Array2dScalarReal64>(d1, 3, 1, 0, 0, true);
00051
00052 if (dy == 2)
00053 kery = MakeFromData<Array2dScalarReal64>(d2, 3, 1, 0, 0, true);
00054
00055
00056 if ((kerx != 0) && (kery != 0))
00057 {
00058 std::cout << "doing it" << std::endl;
00059 ConvKernelSeparated(dst, tmp, kerx, kery);
00060 }
00061 else
00062 {
00063 if (kerx != 0)
00064 ConvKernel1d(dst, tmp, 1, kerx);
00065 else
00066 ConvKernel1d(dst, tmp, 2, kery);
00067 }
00068 delete kerx;
00069 delete kery;
00070 delete tmp;
00071 }
00072
00073 }
00074 }
00075 }
00076
00077 #endif