00001 #ifndef Impala_Core_Array_Pattern_PatRecGenConv2d_h
00002 #define Impala_Core_Array_Pattern_PatRecGenConv2d_h
00003
00004 #include "Core/Array/Pattern/PatSet.h"
00005 #include "Core/Array/Pattern/PatSetBorder.h"
00006 #include "Core/Array/Pattern/FuncRecGenConv2d.h"
00007
00008 #ifdef PX_HORUS_USED
00009 #include "Core/Array/Pattern/PxArrayFunc.h"
00010 #include "Core/Array/Pattern/PxStateTrans.h"
00011 #endif
00012
00013 namespace Impala
00014 {
00015 namespace Core
00016 {
00017 namespace Array
00018 {
00019 namespace Pattern
00020 {
00021
00022
00023 template <class DstArrayT, class SrcArrayT, class KerArrayT,
00024 class PixOpT, class RedOpT>
00025 inline void
00026 PatRecGenConv2d(DstArrayT*& dst, SrcArrayT* src, KerArrayT* ker,
00027 PixOpT& pixOp, RedOpT& redOp)
00028 {
00029 int numX = ArrayCW(ker) / 2;
00030 int numY = ArrayCH(ker) / 2;
00031 SrcArrayT* checkedSrc = CheckBorderSize(src, numX, numY);
00032
00033 if (checkedSrc != src)
00034 {
00035 if ((dst != 0) && (dst != src))
00036 delete dst;
00037 dst = checkedSrc;
00038 }
00039 else
00040 {
00041 if (dst != src)
00042 PatSet(dst, src);
00043 }
00044
00045 #ifdef PX_HORUS_USED
00046 if (!PxRunParallel()) {
00047 #endif
00048 PatSetBorder(dst, numX, numY, BORDERPROPAGATE);
00049 FuncRecGenConv2dDispatch(dst, ker, pixOp, redOp);
00050
00051 #ifdef PX_HORUS_USED
00052 } else {
00053 PX_COUT << "NOTE: PatRecGenConv2d NOT PARALLELIZED YET!"
00054 << PX_ENDL;
00055 PxArrayForceNonDistributed(dst);
00056 PatSetBorder(dst, numX, numY, BORDERPROPAGATE);
00057 FuncRecGenConv2dDispatch(dst, ker, pixOp, redOp);
00058 }
00059 #endif
00060 }
00061
00062 }
00063 }
00064 }
00065 }
00066
00067 #endif