Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

Harris.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Array_Harris_h
00002 #define Impala_Core_Array_Harris_h
00003 
00004 #include <vector>
00005 #include "Core/Array/Arrays.h"
00006 #include "Core/Array/RecGauss.h"
00007 #include "Core/Array/GaussDerivative.h"
00008 #include "Core/Array/Mul.h"
00009 #include "Core/Array/Add.h"
00010 #include "Core/Array/Norm2Sqr.h"
00011 #include "Core/Array/ArrayListDelete.h"
00012 #include "Core/Array/Pattern/PatM3PixOp.h"
00013 #include "Core/Array/Trait/M3poHarris.h"
00014 #include "Core/Array/Trait/M3poNorm2Sqr.h"
00015 #include "Core/Array/Pattern/PatM9PixOp.h"
00016 #include "Core/Array/Trait/M9poHx.h"
00017 #include "Core/Array/Trait/M9poHy.h"
00018 #include "Core/Array/Pattern/PatM9N4PixOp.h"
00019 #include "Core/Array/Trait/M9N4poFO.h"
00020 #include "Core/Array/Trait/M9N4poFSph.h"
00021 
00022 namespace Impala
00023 {
00024 namespace Core
00025 {
00026 namespace Array
00027 {
00028 
00029 
00030 // The real thing : computes Lx2*Ly2 - LxLy*LxLy - _k*(Lx2+Ly2)*(Lx2+Ly2)
00031 template<class DstArrayT, class SrcArrayT>
00032 inline void
00033 Harris(DstArrayT*& dst, SrcArrayT* Lx2, SrcArrayT* Ly2, SrcArrayT* LxLy,
00034        Real64 sigmaA, Real64 k, bool useRecGauss = false)
00035 {
00036     DstArrayT* Lx2g = 0;
00037     DstArrayT* Ly2g = 0;
00038     DstArrayT* LxLyg = 0;
00039     if (useRecGauss)
00040     {
00041         RecGauss(Lx2g, Lx2, sigmaA, sigmaA, 0, 0, 3);
00042         RecGauss(Ly2g, Ly2, sigmaA, sigmaA, 0, 0, 3);
00043         RecGauss(LxLyg, LxLy, sigmaA, sigmaA, 0, 0, 3);
00044     }
00045     else
00046     {
00047         GaussDerivative(Lx2g, Lx2, sigmaA, 0, 0, 3.0);
00048         GaussDerivative(Ly2g, Ly2, sigmaA, 0, 0, 3.0);
00049         GaussDerivative(LxLyg, LxLy, sigmaA, 0, 0, 3.0);
00050     }
00051 
00052     Trait::M3poHarris<DstArrayT, SrcArrayT> mpo(k);
00053     Pattern::PatM3PixOp(dst, Lx2g, Ly2g, LxLyg, mpo);
00054 
00055     delete Lx2g;
00056     delete Ly2g;
00057     delete LxLyg;
00058 }
00059 
00060 // Harris on scalar images
00061 template<class DstArrayT, class SrcArrayT>
00062 inline void
00063 Harris(DstArrayT*& dst, SrcArrayT* Lx, SrcArrayT* Ly,
00064        Real64 sigmaA, Real64 k, bool useRecGauss = false)
00065 {
00066     DstArrayT* Lx2 = 0;
00067     Mul(Lx2, Lx, Lx);
00068     DstArrayT* Ly2 = 0;
00069     Mul(Ly2, Ly, Ly);
00070     DstArrayT* LxLy = 0;
00071     Mul(LxLy, Lx, Ly);
00072     Harris(dst, Lx2, Ly2, LxLy, sigmaA, k, useRecGauss);
00073 
00074     delete Lx2;
00075     delete Ly2;
00076     delete LxLy;
00077 }
00078 
00079 // Harris on vec2 images
00080 template<class DstArrayT, class SrcArrayT>
00081 inline void
00082 Harris(DstArrayT*& dst, SrcArrayT* Lx, SrcArrayT* Ly, SrcArrayT* Lxd2,
00083        SrcArrayT* Lyd2, Real64 sigmaA, Real64 k, bool useRecGauss = false)
00084 {
00085     DstArrayT* Lx2 = 0;
00086     Norm2Sqr(Lx2, Lx, Lxd2);
00087     DstArrayT* Ly2 = 0;
00088     Norm2Sqr(Ly2, Ly, Lyd2);
00089     DstArrayT* LxLy = 0;
00090     Mul(LxLy, Lx, Ly);
00091     DstArrayT* tmp = 0;
00092     Mul(tmp, Lxd2, Lyd2);
00093     Add(LxLy, LxLy, tmp);
00094     Harris(dst, Lx2, Ly2, LxLy, sigmaA, k, useRecGauss);
00095 
00096     delete tmp;
00097     delete Lx2;
00098     delete Ly2;
00099     delete LxLy;
00100 }
00101 
00102 // Harris on vec3 images
00103 template<class DstArrayT, class SrcArrayT>
00104 inline void
00105 Harris(DstArrayT*& dst, SrcArrayT* Lx, SrcArrayT* Ly, SrcArrayT* Lxd2,
00106        SrcArrayT* Lyd2, SrcArrayT* Lxd3, SrcArrayT* Lyd3, Real64 sigmaA,
00107        Real64 k, bool useRecGauss = false)
00108 {
00109     Trait::M3poNorm2Sqr<DstArrayT, SrcArrayT> mpo;
00110     DstArrayT* Lx2 = 0;
00111     Pattern::PatM3PixOp(Lx2, Lx, Lxd2, Lxd3, mpo);
00112     DstArrayT* Ly2 = 0;
00113     Pattern::PatM3PixOp(Ly2, Ly, Lyd2, Lyd3, mpo);
00114     DstArrayT* LxLy = 0;
00115     Mul(LxLy, Lx, Ly);
00116     DstArrayT* tmp = 0;
00117     Mul(tmp, Lxd2, Lyd2);
00118     Add(LxLy, LxLy, tmp);
00119     Mul(tmp, Lxd3, Lyd3);
00120     Add(LxLy, LxLy, tmp);
00121     Harris(dst, Lx2, Ly2, LxLy, sigmaA, k, useRecGauss);
00122 
00123     delete tmp;
00124     delete Lx2;
00125     delete Ly2;
00126     delete LxLy;
00127 }
00128 
00129 
00130 // relies on rgbList to contain R, Rx, Ry, G, Gx, Gy, B, Bx, By
00131 template<class ArrayT>
00132 inline void
00133 HarrisObj(ArrayT*& dst, const std::vector<ArrayT*>& rgbList, double sigmaA,
00134           double k, bool useRecGauss = false)
00135 {
00136     Trait::M9poHx<ArrayT, ArrayT> mpoHx;
00137     ArrayT* hx = 0;
00138     Pattern::PatM9PixOp(hx,
00139                         rgbList[0], rgbList[3], rgbList[6],
00140                         rgbList[1], rgbList[4], rgbList[7],
00141                         rgbList[2], rgbList[5], rgbList[8],
00142                         mpoHx);
00143 
00144     Trait::M9poHy<Array2dScalarReal64, Array2dScalarReal64> mpoHy;
00145     ArrayT* hy = 0;
00146     Pattern::PatM9PixOp(hy,
00147                         rgbList[0], rgbList[3], rgbList[6],
00148                         rgbList[1], rgbList[4], rgbList[7],
00149                         rgbList[2], rgbList[5], rgbList[8],
00150                         mpoHy);
00151 
00152     Harris(dst, hx, hy, sigmaA, k, useRecGauss);
00153     delete hx;
00154     delete hy;
00155 }
00156 
00157 // relies on rgbList to contain R, Rx, Ry, G, Gx, Gy, B, Bx, By
00158 template<class ArrayT>
00159 inline void
00160 HarrisSperical(ArrayT*& dst, const std::vector<ArrayT*>& rgbList, double sigmaA,
00161                double k, bool useRecGauss = false)
00162 {
00163     Trait::M9N4poFSph<ArrayT, ArrayT> mnpoFSph;
00164     std::vector<ArrayT*> fList;
00165     fList = Pattern::PatM9N4PixOp<ArrayT>(rgbList[0], rgbList[3], rgbList[6],
00166                                           rgbList[1], rgbList[4], rgbList[7],
00167                                           rgbList[2], rgbList[5], rgbList[8],
00168                                           mnpoFSph);
00169 
00170     Harris(dst, fList[0], fList[1], fList[2], fList[3], sigmaA, k, useRecGauss);
00171     ArrayListDelete(&fList);
00172 }
00173 
00174 // relies on rgbList to contain R, Rx, Ry, G, Gx, Gy, B, Bx, By
00175 template<class ArrayT>
00176 inline void
00177 HarrisOpponent(ArrayT*& dst, const std::vector<ArrayT*>& rgbList, double sigmaA,
00178                double k, bool useRecGauss = false)
00179 {
00180     Trait::M9N4poFO<ArrayT, ArrayT> mnpoFO;
00181     std::vector<ArrayT*> fList;
00182     fList = Pattern::PatM9N4PixOp<ArrayT>(rgbList[0], rgbList[3], rgbList[6],
00183                                           rgbList[1], rgbList[4], rgbList[7],
00184                                           rgbList[2], rgbList[5], rgbList[8],
00185                                           mnpoFO);
00186 
00187     Harris(dst, fList[0], fList[1], fList[2], fList[3], sigmaA, k, useRecGauss);
00188     ArrayListDelete(&fList);
00189 }
00190 
00191 // relies on rgbList to contain R, Rx, Ry, G, Gx, Gy, B, Bx, By
00192 template<class ArrayT>
00193 inline void
00194 HarrisRGB(ArrayT*& dst, const std::vector<ArrayT*>& rgbList, double sigmaA,
00195           double k, bool useRecGauss = false)
00196 {
00197     Harris(dst, rgbList[1], rgbList[2], rgbList[4], rgbList[5],
00198            rgbList[7], rgbList[8], sigmaA, k, useRecGauss);
00199 }
00200 
00201 } // namespace Array
00202 } // namespace Core
00203 } // namespace Impala
00204 
00205 #endif

Generated on Fri Mar 19 09:30:46 2010 for ImpalaSrc by  doxygen 1.5.1