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

FuncInOut.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Array_Pattern_FuncInOut_h
00002 #define Impala_Core_Array_Pattern_FuncInOut_h
00003 
00004 #include "Core/Array/Pattern/Categories.h"
00005 #include "Core/Array/Pattern/ArrayFunc.h"
00006 #include "Core/Array/Pattern/PtrFunc.h"
00007 
00008 namespace Impala
00009 {
00010 namespace Core
00011 {
00012 namespace Array
00013 {
00014 namespace Pattern
00015 {
00016 
00017 
00018 /**********************************************************************/
00055 template <class ArrayT, class PixOpT>
00056 inline void
00057 FuncInOut_Row_InTi(ArrayT* a, PixOpT& pixOp, int y)
00058 {
00059     typedef typename ArrayT::StorType StorT;
00060 
00061     StorT* ptr = ArrayCPB(a, 0, y);
00062     int width = ArrayCW(a);
00063     while (--width >= 0)
00064     {
00065         PtrWrite(ptr, pixOp.DoIt());
00066         ptr += ArrayT::ElemSize();
00067     }
00068 }
00069 
00071 template <class ArrayT, class PixOpT>
00072 inline void
00073 FuncInOut_Row_OutTi(ArrayT* a, PixOpT& pixOp, int y)
00074 {
00075     typedef typename ArrayT::StorType StorT;
00076     typedef typename ArrayT::ArithType ArithT;
00077 
00078     StorT* ptr = ArrayCPB(a, 0, y);
00079     int width = ArrayCW(a);
00080     while (--width >= 0)
00081     {
00082         pixOp.DoIt(PtrRead(ptr, ArithT()));
00083         ptr += ArrayT::ElemSize();
00084     }
00085 }
00086 
00088 template <class ArrayT, class PixOpT>
00089 inline void
00090 FuncInOut_Row_InTv(ArrayT* a, PixOpT& pixOp, int y)
00091 {
00092     typedef typename ArrayT::StorType StorT;
00093 
00094     StorT* ptr = ArrayCPB(a, 0, y);
00095     int width = ArrayCW(a);
00096     for (int x=0 ; x<width ; x++)
00097     {
00098         PtrWrite(ptr, pixOp.DoIt(x, y));
00099         ptr += ArrayT::ElemSize();
00100     }
00101 }
00102 
00104 template <class ArrayT, class PixOpT>
00105 inline void
00106 FuncInOut_Row_OutTv(ArrayT* a, PixOpT& pixOp, int y)
00107 {
00108     typedef typename ArrayT::StorType StorT;
00109     typedef typename ArrayT::ArithType ArithT;
00110 
00111     StorT* ptr = ArrayCPB(a, 0, y);
00112     int width = ArrayCW(a);
00113     for (int x=0 ; x<width ; x++)
00114     {
00115         pixOp.DoIt(PtrRead(ptr, ArithT()), x, y);
00116         ptr += ArrayT::ElemSize();
00117     }
00118 }
00119 
00121 //End of Row_variations.
00122 
00123 
00125 
00129 template <class ArrayT, class PixOpT>
00130 void
00131 FuncInOut(ArrayT* a, PixOpT& pixOp,
00132           TagPixOpIn dummy1, TagTransInVar dummy2, Tag1Phase dummy3)
00133 {
00134     int height = ArrayCH(a);
00135     for (int y=0 ; y<height ; y++)
00136         FuncInOut_Row_InTi(a, pixOp, y);
00137 }
00138 
00141 template <class ArrayT, class PixOpT>
00142 void
00143 FuncInOut(ArrayT* a, PixOpT& pixOp,
00144           TagPixOpOut dummy1, TagTransInVar dummy2, Tag1Phase dummy3)
00145 {
00146     int height = ArrayCH(a);
00147     for (int y=0 ; y<height ; y++)
00148         FuncInOut_Row_OutTi(a, pixOp, y);
00149 }
00150 
00153 template <class ArrayT, class PixOpT>
00154 void
00155 FuncInOut(ArrayT* a, PixOpT& pixOp,
00156           TagPixOpIn dummy1, TagTransVar dummy2, Tag1Phase dummy3)
00157 {
00158     int height = ArrayCH(a);
00159     for (int y=0 ; y<height ; y++)
00160         FuncInOut_Row_InTv(a, pixOp, y);
00161 }
00162 
00165 template <class ArrayT, class PixOpT>
00166 void
00167 FuncInOut(ArrayT* a, PixOpT& pixOp,
00168           TagPixOpOut dummy1, TagTransVar dummy2, Tag1Phase dummy3)
00169 {
00170     int height = ArrayCH(a);
00171     for (int y=0 ; y<height ; y++)
00172         FuncInOut_Row_OutTv(a, pixOp, y);
00173 }
00174 
00177 template <class ArrayT, class PixOpT>
00178 void
00179 FuncInOut(ArrayT* a, PixOpT& pixOp,
00180           TagPixOpIn dummy1, TagTransInVar dummy2, TagNPhase dummy3)
00181 {
00182     int height = ArrayCH(a);
00183     for (int phase=1 ; phase<=pixOp.NrPhases() ; phase++)
00184     {
00185         pixOp.Init(phase);
00186         for (int y=0 ; y<height ; y++)
00187             FuncInOut_Row_InTi(a, pixOp, y);
00188         pixOp.Done(phase);
00189     }
00190 }
00191 
00194 template <class ArrayT, class PixOpT>
00195 void
00196 FuncInOut(ArrayT* a, PixOpT& pixOp,
00197           TagPixOpOut dummy1, TagTransInVar dummy2, TagNPhase dummy3)
00198 {
00199     int height = ArrayCH(a);
00200     for (int phase=1 ; phase<=pixOp.NrPhases() ; phase++)
00201     {
00202         pixOp.Init(phase);
00203         for (int y=0 ; y<height ; y++)
00204             FuncInOut_Row_OutTi(a, pixOp, y);
00205         pixOp.Done(phase);
00206     }
00207 }
00208 
00211 template <class ArrayT, class PixOpT>
00212 void
00213 FuncInOut(ArrayT* a, PixOpT& pixOp,
00214           TagPixOpIn dummy1, TagTransVar dummy2, TagNPhase dummy3)
00215 {
00216     int height = ArrayCH(a);
00217     for (int phase=1 ; phase<=pixOp.NrPhases() ; phase++)
00218     {
00219         pixOp.Init(phase);
00220         for (int y=0 ; y<height ; y++)
00221             FuncInOut_Row_InTv(a, pixOp, y);
00222         pixOp.Done(phase);
00223     }
00224 }
00225 
00228 template <class ArrayT, class PixOpT>
00229 void
00230 FuncInOut(ArrayT* a, PixOpT& pixOp,
00231           TagPixOpOut dummy1, TagTransVar dummy2, TagNPhase dummy3)
00232 {
00233     int height = ArrayCH(a);
00234     for (int phase=1 ; phase<=pixOp.NrPhases() ; phase++)
00235     {
00236         pixOp.Init(phase);
00237         for (int y=0 ; y<height ; y++)
00238             FuncInOut_Row_OutTv(a, pixOp, y);
00239         pixOp.Done(phase);
00240     }
00241 }
00242 
00244 //End of InOut_variations.
00245 
00246 
00250 template <class ArrayT, class PixOpT>
00251 void
00252 FuncInOutDispatch(ArrayT* a, PixOpT& pixOp)
00253 {
00254     FuncInOut(a, pixOp, typename PixOpT::DirectionCategory(),
00255               typename PixOpT::TransVarianceCategory(),
00256               typename PixOpT::PhaseCategory());
00257 }
00258 
00259 /***************************************************
00260  * functions for im/exporting from multiple images *
00261  * only implemented for translation invariant      *
00262  * and 1 phase                                     *
00263  ***************************************************/
00264 
00265 template <class ArrayT, class PixOpT>
00266 void
00267 FuncM2InOutDispatch(ArrayT* a, ArrayT* b, PixOpT& pixOp)
00268 {
00269     typedef typename ArrayT::StorType StorT;
00270 
00271     int width = ArrayCW(a);
00272     int height = ArrayCH(a);
00273     for (int y=0 ; y<height ; y++)
00274     {
00275         StorT* aPtr = ArrayCPB(a, 0, y);
00276         StorT* bPtr = ArrayCPB(b, 0, y);
00277         for (int x=0 ; x<width ; x++)
00278         {
00279             pixOp.DoIt(aPtr, bPtr);
00280             aPtr += ArrayT::ElemSize();
00281             bPtr += ArrayT::ElemSize();
00282         }
00283     }
00284 }
00285 
00286 template <class ArrayT, class PixOpT>
00287 void
00288 FuncM3InOutDispatch(ArrayT* a, ArrayT* b, ArrayT* c, PixOpT& pixOp)
00289 {
00290     typedef typename ArrayT::StorType StorT;
00291 
00292     int width = ArrayCW(a);
00293     int height = ArrayCH(a);
00294     for (int y=0 ; y<height ; y++)
00295     {
00296         StorT* aPtr = ArrayCPB(a, 0, y);
00297         StorT* bPtr = ArrayCPB(b, 0, y);
00298         StorT* cPtr = ArrayCPB(c, 0, y);
00299         for (int x=0 ; x<width ; x++)
00300         {
00301             pixOp.DoIt(aPtr, bPtr, cPtr);
00302             aPtr += ArrayT::ElemSize();
00303             bPtr += ArrayT::ElemSize();
00304             cPtr += ArrayT::ElemSize();
00305         }
00306     }
00307 }
00308 
00309 
00311 // michiel: for 2d histogram only the variation we need
00312 
00313 
00315 template <class ArrayT, class PixOpT>
00316 inline void
00317 FuncInOut_Row_OutTi(ArrayT* a, ArrayT* b, PixOpT& pixOp, int y)
00318 {
00319     typedef typename ArrayT::StorType StorT;
00320     typedef typename ArrayT::ArithType ArithT;
00321 
00322     StorT* ptrA = ArrayCPB(a, 0, y);
00323     StorT* ptrB = ArrayCPB(b, 0, y);
00324     int width = ArrayCW(a);
00325     while (--width >= 0)
00326     {
00327         pixOp.DoIt(PtrRead(ptrA, ArithT()), PtrRead(ptrB, ArithT()));
00328         ptrA += ArrayT::ElemSize();
00329         ptrB += ArrayT::ElemSize();
00330     }
00331 }
00332 
00335 template <class ArrayT, class PixOpT>
00336 void
00337 FuncInOut(ArrayT* a, ArrayT* b, PixOpT& pixOp,
00338           TagPixOpOut dummy1, TagTransInVar dummy2, Tag1Phase dummy3)
00339 {
00340     int height = ArrayCH(a);
00341     for (int y=0 ; y<height ; y++)
00342         FuncInOut_Row_OutTi(a, b, pixOp, y);
00343 }
00344 
00345 // note: actually doesn't dispatch since only export, translation invariant,
00346 // 1 phase is implemented
00347 template <class ArrayT, class PixOpT>
00348 void
00349 FuncInOutDispatch(ArrayT* a, ArrayT* b, PixOpT& pixOp)
00350 {
00351     FuncInOut(a, b, pixOp,
00352               typename PixOpT::DirectionCategory(),
00353               typename PixOpT::TransVarianceCategory(),
00354               typename PixOpT::PhaseCategory());
00355 }
00356 
00357 } // namespace Pattern
00358 } // namespace Array
00359 } // namespace Core
00360 } // namespace Impala
00361 
00362 #endif

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