00001 #ifndef Impala_Core_Array_Pattern_PatGenConv2dSep_h
00002 #define Impala_Core_Array_Pattern_PatGenConv2dSep_h
00003
00004 #include "Core/Array/CheckBorderSize.h"
00005 #include "Core/Array/Pattern/PatSetBorder.h"
00006 #include "Core/Array/Pattern/FuncGenConv2dSep.h"
00007 #include "Util/TimePlot.h"
00008
00009 #ifdef PX_HORUS_USED
00010 #include "Core/Array/Pattern/PxArrayFunc.h"
00011 #include "Core/Array/Pattern/PxStateTrans.h"
00012 #endif
00013
00014 namespace Impala
00015 {
00016 namespace Core
00017 {
00018 namespace Array
00019 {
00020 namespace Pattern
00021 {
00022
00023
00024 template<class DstArrayT, class SrcArrayT, class KerArrayT,
00025 class PixOpT, class RedOpT>
00026 inline void
00027 PatGenConv2dSep(DstArrayT*& dst, SrcArrayT* src, KerArrayT* ker1,
00028 KerArrayT* ker2, PixOpT& pixOp, RedOpT& redOp,
00029 int vType, Util::TimePlot* plotter)
00030 {
00031 if (vType == 6)
00032 vType = 0;
00033
00034 int numX = ArrayCW(ker1) / 2;
00035 int numY = ArrayCW(ker2) / 2;
00036 SrcArrayT* checkedSrc = CheckBorderSize(src, numX, numY);
00037
00038 if ((dst == 0) || (dst == checkedSrc))
00039 dst = ArrayClone<DstArrayT>(checkedSrc);
00040
00041 #ifdef PX_HORUS_USED
00042 if (!PxRunParallel()) {
00043 #endif
00044 if (plotter)
00045 plotter->SplitTime();
00046 if ((vType == 0) || (vType == 1) || (vType == 2))
00047 {
00048 PatSetBorder(checkedSrc, numX, 0);
00049 if (plotter)
00050 plotter->SplitTime();
00051 KerArrayT* scratch = ArrayClone<KerArrayT>(checkedSrc);
00052 if (plotter)
00053 plotter->SplitTime();
00054 FuncGenConv2dSepDispatch_H(scratch, checkedSrc,
00055 ker1, pixOp, redOp, vType);
00056 if (plotter)
00057 plotter->SplitTime();
00058 PatSetBorder(scratch, 0, numY);
00059 if (plotter)
00060 plotter->SplitTime();
00061 FuncGenConv2dSepDispatch_V(dst, scratch,
00062 ker2, pixOp, redOp, vType);
00063 delete scratch;
00064 }
00065 else
00066 {
00067 PatSetBorder(checkedSrc, numX, numY);
00068 if (plotter)
00069 plotter->SplitTime();
00070 if (plotter)
00071 plotter->SplitTime();
00072 if (plotter)
00073 plotter->SplitTime();
00074 if (plotter)
00075 plotter->SplitTime();
00076
00077
00078 }
00079
00080 #ifdef PX_HORUS_USED
00081 } else {
00082 PxArrayPreStateTrans(checkedSrc, PAR_PART, STRONG);
00083 PxArrayPreStateTrans(dst, PAR_PART, WEAK);
00084 if ((vType == 0) || (vType == 1) || (vType == 2)) {
00085 PatSetBorder(PxArrayPD(checkedSrc), numX, 0);
00086 KerArrayT* scratch =
00087 ArrayClone<KerArrayT>(PxArrayPD(checkedSrc));
00088 FuncGenConv2dSepDispatch_H(scratch, PxArrayPD(checkedSrc),
00089 ker1, pixOp, redOp, vType);
00090 PatSetBorder(scratch, 0, numY);
00091 FuncGenConv2dSepDispatch_V(PxArrayPD(dst), scratch,
00092 ker2, pixOp, redOp, vType);
00093 delete scratch;
00094 } else {
00095 PatSetBorder(PxArrayPD(checkedSrc), numX, numY);
00096
00097
00098
00099 }
00100 if (PxArrayPD(checkedSrc) != PxArrayPD(src))
00101 PxArrayDeletePD(checkedSrc);
00102 PxArrayPostStateTrans(dst);
00103
00104 if (!PxRunLazyParallel()) {
00105 PxArrayForceNonDistributed(src);
00106 PxArrayForceNonDistributed(dst);
00107 }
00108 }
00109 #endif
00110
00111 if (checkedSrc != src)
00112 delete checkedSrc;
00113 }
00114
00115 }
00116 }
00117 }
00118 }
00119
00120 #endif