00001 #ifndef Impala_Core_Array_VisSemGabor_h
00002 #define Impala_Core_Array_VisSemGabor_h
00003
00004 #include <vector>
00005 #include "Core/Array/Arrays.h"
00006 #include "Core/Array/ArraySet.h"
00007 #include "Core/Array/Rgb2Ooo.h"
00008 #include "Core/Array/Set.h"
00009 #include "Core/Array/Add.h"
00010 #include "Core/Array/Sub.h"
00011 #include "Core/Array/Div.h"
00012 #include "Core/Array/Mul.h"
00013 #include "Core/Array/Norm2.h"
00014 #include "Core/Array/Threshold.h"
00015 #include "Core/Array/RecGabor.h"
00016 #include "Core/Array/RecGauss.h"
00017 #include "Core/Array/PixStat.h"
00018 #include "Core/Array/ProjectRange.h"
00019
00020 namespace Impala
00021 {
00022 namespace Core
00023 {
00024 namespace Array
00025 {
00026
00027
00028 inline void
00029 VisSemGabor(ArraySet<Array2dScalarReal64>& res, Array2dVec3UInt8* rgb,
00030 double scale, double freq, int nrOrient)
00031 {
00032
00033
00034
00035 res.Array("gaborW0");
00036 res.Array("gaborWl0");
00037 res.Array("gaborWll0");
00038 res.Array("gaborW45");
00039 res.Array("gaborWl45");
00040 res.Array("gaborWll45");
00041 res.Array("gaborW90");
00042 res.Array("gaborWl90");
00043 res.Array("gaborWll90");
00044 res.Array("gaborW135");
00045 res.Array("gaborWl135");
00046 res.Array("gaborWll135");
00047 res.Array("Wl");
00048 res.Array("Wll");
00049
00050 if (!rgb)
00051 return;
00052
00053
00054 double* orients = new double[nrOrient];
00055 orients[0] = 0;
00056 for (int i=1 ; i<nrOrient; i++)
00057 orients[i] = orients[i-1] + M_PI/nrOrient;
00058
00059
00060 Array2dVec3Real64* ooo = 0;
00061 Rgb2Ooo(ooo, rgb);
00062
00063
00064 Array2dScalarReal64* E_0_SR64 = 0;
00065 Array2dComplex64* E_0_C64 = 0;
00066 Array2dComplex64* gabor = 0;
00067 Array2dScalarReal64* tmp_SR64 = 0;
00068 Array2dComplex64* tmp_C64 = 0;
00069
00070
00071 Array2dScalarReal64* imOOO_SR64[3];
00072 Array2dComplex64* imOOO_C64[3];
00073 for (int ii=0 ; ii<3 ; ii++) {
00074 imOOO_SR64[ii] = 0;
00075 ProjectRange(imOOO_SR64[ii], ooo, ii+1);
00076 imOOO_C64[ii] = 0;
00077 Set(imOOO_C64[ii], imOOO_SR64[ii]);
00078 }
00079
00080
00081 RecGauss(E_0_SR64, imOOO_SR64[0], scale, scale, 0, 0, 3);
00082
00083
00084 int thresholdVal = 15;
00085 Array2dScalarReal64* threshE_0_SR64 = 0;
00086 Threshold(threshE_0_SR64, E_0_SR64, thresholdVal);
00087
00088
00089
00090
00091
00092
00093
00094 int cur = 0;
00095
00096
00097 for (int oi=0; oi<nrOrient; oi++)
00098 {
00099
00100 for (int pixDim=0;pixDim<3 ; pixDim++)
00101 {
00102
00103 Set(tmp_C64, imOOO_SR64[pixDim]);
00104 RecGabor(gabor, tmp_C64, scale, freq, orients[oi]);
00105
00106
00107
00108 Norm2(res.Array(cur), gabor);
00109
00110
00111 Div(res.Array(cur), res.Array(cur), E_0_SR64);
00112
00113
00114
00115
00116
00117 Mul(res.Array(cur), res.Array(cur), threshE_0_SR64);
00118
00119
00120
00121 cur++;
00122
00123 }
00124 }
00125
00126
00127
00128
00129
00130 for (int pixDim=1 ; pixDim<3 ; pixDim++)
00131 {
00132
00133
00134 RecGauss(res.Array(cur), imOOO_SR64[pixDim], scale, scale, 0, 0, 3);
00135
00136
00137 Div(res.Array(cur), res.Array(cur), E_0_SR64);
00138
00139
00140 Mul(res.Array(cur), res.Array(cur), threshE_0_SR64);
00141
00142
00143 cur++;
00144 }
00145
00146
00147 delete orients;
00148 for (int j=0 ; j<3 ; j++) {
00149 delete imOOO_SR64[j];
00150 delete imOOO_C64[j];
00151 }
00152 delete E_0_SR64;
00153 delete E_0_C64;
00154 delete gabor;
00155 delete tmp_SR64;
00156 delete tmp_C64;
00157 delete threshE_0_SR64;
00158 delete ooo;
00159 }
00160
00161 }
00162 }
00163 }
00164
00165 #endif