00001 #ifndef Impala_Core_Array_Laplacian_h
00002 #define Impala_Core_Array_Laplacian_h
00003
00004 #include "Core/Array/GaussDerivative.h"
00005 #include "Core/Array/RecGauss.h"
00006 #include "Core/Array/MulVal.h"
00007 #include "Core/Array/Abs.h"
00008 #include "Core/Array/Add.h"
00009 #include "Core/Array/Set.h"
00010
00011 namespace Impala
00012 {
00013 namespace Core
00014 {
00015 namespace Array
00016 {
00017
00018 void
00019 Laplacian(Array2dScalarReal64*& dst, Array2dScalarReal64* src, Real64 sigma,
00020 int gamma, bool useRecGauss, double precision)
00021 {
00022
00023
00024 Array2dScalarReal64* Lxx = 0;
00025 Array2dScalarReal64* Lyy = 0;
00026
00027 if(useRecGauss)
00028 {
00029 RecGauss(Lxx, src, sigma, sigma, 2, 0, precision);
00030 RecGauss(Lyy, src, sigma, sigma, 0, 2, precision);
00031 }
00032 else
00033 {
00034 GaussDerivative(Lxx, src, sigma, 2, 0, precision);
00035 GaussDerivative(Lyy, src, sigma, 0, 2, precision);
00036 }
00037
00038 Add(dst, Lxx, Lyy);
00039 delete Lxx;
00040 delete Lyy;
00041 Real64 sigma2 = 1;
00042 for(int i = 0; i < gamma; i++)
00043 sigma2 = sigma2 * sigma;
00044 MulVal(dst, dst, sigma2);
00045 }
00046
00047
00048
00049 template<class SrcArrayT>
00050 void
00051 Laplacian(Array2dScalarReal64*& dst, SrcArrayT* src, Real64 sigma, int gamma,
00052 bool useRecGauss, double precision)
00053 {
00054 for (int d=1 ; d<=src->ElemSize() ; d++)
00055 {
00056 Array2dScalarReal64* imIntensity = 0;
00057 ProjectRange(imIntensity, src, d);
00058 Array2dScalarReal64* temp = 0;
00059 Laplacian(temp, imIntensity, sigma, gamma, useRecGauss, precision);
00060 if(d == 1)
00061 {
00062 Set(dst, temp);
00063 }
00064 else
00065 {
00066 Add(dst, dst, temp);
00067 }
00068 delete imIntensity;
00069 delete temp;
00070 }
00071 }
00072
00073 }
00074 }
00075 }
00076
00077 #endif