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

InvWiccest.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Array_InvWiccest_h
00002 #define Impala_Core_Array_InvWiccest_h
00003 
00004 #include <vector>
00005 #include "Core/Array/Arrays.h"
00006 #include "Core/Array/ArraySet.h"
00007 #include "Core/Array/InvCompDer.h"
00008 #include "Core/Array/InvCxy.h"
00009 #include "Core/Array/Rgb2Ooo.h"
00010 #include "Core/Array/Add.h"
00011 #include "Core/Array/Sub.h"
00012 #include "Core/Array/Div.h"
00013 #include "Core/Array/DivVal.h"
00014 #include "Core/Array/Norm2Sqr.h"
00015 #include "Core/Array/ArrayListDelete.h"
00016 #include "Core/Array/Pattern/PatM9N4PixOp.h"
00017 #include "Core/Array/Trait/M9N4poCxy.h"
00018 
00019 namespace Impala
00020 {
00021 namespace Core
00022 {
00023 namespace Array
00024 {
00025 
00026 
00027 /*
00028 input is an rgb image output is a list of:
00029 - gradient (Ex*Ex + Ey*Ey)
00030 - Wx
00031 - W 45
00032 - Wy
00033 - W 135
00034 - Clx
00035 - Cl 45
00036 - Cly
00037 - Cl 135
00038 - Cllx
00039 - Cll 45
00040 - Clly
00041 - Cll 135
00042 
00043 perhaps it would be better to return gradient through another parameter??
00044 */
00045 
00046 inline std::vector<Array2dScalarReal64*>
00047 InvWiccest(Array2dVec3UInt8* rgb, double derivativeSigma)
00048 {
00049     std::vector<Array2dScalarReal64*> result;
00050     result.resize(13);
00051     for(int i=0 ; i<13 ; ++i)
00052         result[i] = new Array2dScalarReal64(rgb->CW(), rgb->CH(), rgb->BW(),
00053                                             rgb->BH());
00054 
00055     // convert to ooo
00056     Array2dVec3Real64* ooo = new Array2dVec3Real64(rgb->mCW, rgb->mCH, 0, 0);
00057     Rgb2Ooo(ooo, rgb);
00058     std::vector<Array2dScalarReal64*> listDer = InvCompDer(ooo, derivativeSigma,
00059                                                            3);
00060     delete ooo;
00061 
00062     // compute Wx and Wy
00063     Div(result[1], listDer[1], listDer[0]);
00064     Div(result[3], listDer[2], listDer[0]);
00065 
00066     // compute {Cl,Cll}{x,y}
00067     Trait::M9N4poCxy<Array2dScalarReal64, Array2dScalarReal64> mnpoConFeat;
00068     Pattern::PatM9N4PixOp(result[5], result[7], result[9], result[11],
00069                           listDer[0], listDer[1], listDer[2],
00070                           listDer[3], listDer[4], listDer[5],
00071                           listDer[6], listDer[7], listDer[8], mnpoConFeat);
00072 
00073     // compute the rest
00074     Norm2Sqr(result[0], listDer[1], listDer[2]); //gradient
00075     Add(result[ 2], result[1], result[3]); //W 45
00076     Sub(result[ 4], result[1], result[3]); //W 135
00077     Add(result[ 6], result[5], result[7]); //Cl 45
00078     Sub(result[ 8], result[5], result[7]); //Cl 135
00079     Add(result[10], result[9], result[11]); //Cll 45
00080     Sub(result[12], result[9], result[11]); //Cll 135
00081 
00082     for(int i=0 ; i<listDer.size() ; i++)
00083         delete listDer[i];
00084 
00085     return result;
00086 }
00087 
00088 inline void
00089 InvWiccest(ArraySet<Array2dScalarReal64>& res, Array2dVec3Real64* ooo,
00090            Array2dVec3Real64* ooot, bool doRotation, bool doC, double sigma,
00091            double precision, bool useRecGauss)
00092 {
00093     // this will keep arrays in a specific order if the set is empty:
00094     res.Array("Wx");
00095     if (doRotation)
00096         res.Array("W45");
00097     res.Array("Wy");
00098     if (doRotation)
00099         res.Array("W135");
00100     res.Array("Wlx");
00101     if (doRotation)
00102         res.Array("Wl45");
00103     res.Array("Wly");
00104     if (doRotation)
00105         res.Array("Wl135");
00106     res.Array("Wllx");
00107     if (doRotation)
00108         res.Array("Wll45");
00109     res.Array("Wlly");
00110     if (doRotation)
00111         res.Array("Wll135");
00112 
00113     if (doC)
00114     {
00115         res.Array("Clx");
00116         res.Array("Cly");
00117         res.Array("Cllx");
00118         res.Array("Clly");
00119     }
00120 
00121     if (ooot) {
00122         res.Array("Et");
00123         res.Array("Elt");
00124         res.Array("Ellt");
00125         res.Array("Wxt");
00126         res.Array("Wyt");
00127         res.Array("Wlxt");
00128         res.Array("Wlyt");
00129         res.Array("Wllxt");
00130         res.Array("Wllyt");
00131     }
00132 
00133     if (!ooo)
00134         return; // call was to figure out what would be the result
00135 
00136     std::vector<Array2dScalarReal64*> oooList;
00137     oooList = InvCompDer(ooo, sigma, precision, useRecGauss);
00138 
00139     /* no invariance
00140     DivVal(res.Array("Wx"), oooList[1], 255.0);
00141     DivVal(res.Array("Wy"), oooList[2], 255.0);
00142     DivVal(res.Array("Wlx"), oooList[4], 255.0);
00143     DivVal(res.Array("Wly"), oooList[5], 255.0);
00144     DivVal(res.Array("Wllx"), oooList[7], 255.0);
00145     DivVal(res.Array("Wlly"), oooList[8], 255.0);
00146     */
00147     Div(res.Array("Wx"), oooList[1], oooList[0]);
00148     Div(res.Array("Wy"), oooList[2], oooList[0]);
00149     Div(res.Array("Wlx"), oooList[4], oooList[0]);
00150     Div(res.Array("Wly"), oooList[5], oooList[0]);
00151     Div(res.Array("Wllx"), oooList[7], oooList[0]);
00152     Div(res.Array("Wlly"), oooList[8], oooList[0]);
00153     if (doRotation)
00154     {
00155                 Add(res.Array("W45"), res.Array("Wx"), res.Array("Wy"));
00156                 Sub(res.Array("W135"), res.Array("Wx"), res.Array("Wy"));
00157                 Add(res.Array("Wl45"), res.Array("Wlx"), res.Array("Wly"));
00158                 Sub(res.Array("Wl135"), res.Array("Wlx"), res.Array("Wly"));
00159                 Add(res.Array("Wll45"), res.Array("Wllx"), res.Array("Wlly"));
00160                 Sub(res.Array("Wll135"), res.Array("Wllx"), res.Array("Wlly"));
00161     }
00162 
00163     if (doC)
00164         InvCxy<Array2dScalarReal64>(res.Array("Clx"), res.Array("Cly"),
00165                                     res.Array("Cllx"), res.Array("Clly"),
00166                                     oooList);
00167 
00168     if (!ooot)
00169     {
00170         ArrayListDelete(&oooList);
00171         return;
00172     }
00173 
00174     std::vector<Array2dScalarReal64*> oootList;
00175     oootList = InvCompDer(ooot, sigma, precision, useRecGauss);
00176     Div(res.Array("Et"),    oootList[0], oooList[0]);
00177     Div(res.Array("Elt"),   oootList[3], oooList[0]);
00178     Div(res.Array("Ellt"),  oootList[6], oooList[0]);
00179     Div(res.Array("Wxt"),   oootList[1], oooList[0]);
00180     Div(res.Array("Wyt"),   oootList[2], oooList[0]);
00181     Div(res.Array("Wlxt"),  oootList[4], oooList[0]);
00182     Div(res.Array("Wlyt"),  oootList[5], oooList[0]);
00183     Div(res.Array("Wllxt"), oootList[7], oooList[0]);
00184     Div(res.Array("Wllyt"), oootList[8], oooList[0]);
00185 
00186     ArrayListDelete(&oooList);
00187     ArrayListDelete(&oootList);
00188 }
00189 
00190 inline void 
00191 InvWiccest(ArraySet<Array2dScalarReal64>& res, Array2dVec3UInt8* rgb,
00192            bool doRotation, bool doC, double sigma, double precision,
00193            bool useRecGauss)
00194 {
00195     Array2dVec3Real64* ooo = 0;
00196     if (rgb)
00197         Rgb2Ooo(ooo, rgb);
00198     InvWiccest(res, ooo, 0, doRotation, doC, sigma, precision, useRecGauss);
00199     if (ooo)
00200         delete ooo;
00201 }
00202 
00203 } // namespace Array
00204 } // namespace Core
00205 } // namespace Impala
00206 
00207 #endif

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