00001 #ifndef Impala_Core_Array_Pattern_PatGenConv2dK1d_h
00002 #define Impala_Core_Array_Pattern_PatGenConv2dK1d_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 PatGenConv2dK1d(DstArrayT*& dst, SrcArrayT* src, int dimension,
00028 KerArrayT* ker, PixOpT& pixOp, RedOpT& redOp,
00029 int vType = 0, Util::TimePlot* plotter = 0)
00030 {
00031 vType = 0;
00032
00033 int numX = (dimension == 1) ? ArrayCW(ker) / 2 : 0;
00034 int numY = (dimension == 1) ? 0 : ArrayCW(ker) / 2;
00035 SrcArrayT* checkedSrc = CheckBorderSize(src, numX, numY);
00036
00037 if ((dst == 0) || (dst == checkedSrc))
00038 dst = ArrayClone<DstArrayT>(checkedSrc);
00039
00040 #ifdef PX_HORUS_USED
00041 if (!PxRunParallel()) {
00042 #endif
00043 if (plotter)
00044 plotter->SplitTime();
00045 PatSetBorder(checkedSrc, numX, numY);
00046 if (plotter)
00047 plotter->SplitTime();
00048 if (dimension == 1)
00049 FuncGenConv2dSepDispatch_H(dst, checkedSrc,
00050 ker, pixOp, redOp, vType);
00051 else
00052 FuncGenConv2dSepDispatch_V(dst, checkedSrc,
00053 ker, pixOp, redOp, vType);
00054
00055 #ifdef PX_HORUS_USED
00056 } else {
00057 PxArrayPreStateTrans(checkedSrc, PAR_PART, STRONG);
00058 PxArrayPreStateTrans(dst, PAR_PART, WEAK);
00059 PatSetBorder(PxArrayPD(checkedSrc), numX, numY);
00060 if (dimension == 1) {
00061 FuncGenConv2dSepDispatch_H(PxArrayPD(dst),
00062 PxArrayPD(checkedSrc), ker, pixOp, redOp, vType);
00063 } else {
00064 FuncGenConv2dSepDispatch_V(PxArrayPD(dst),
00065 PxArrayPD(checkedSrc), ker, pixOp, redOp, vType);
00066 }
00067 if (PxArrayPD(checkedSrc) != PxArrayPD(src))
00068 PxArrayDeletePD(checkedSrc);
00069 PxArrayPostStateTrans(dst);
00070
00071 if (!PxRunLazyParallel()) {
00072 PxArrayForceNonDistributed(src);
00073 PxArrayForceNonDistributed(dst);
00074 }
00075 }
00076 #endif
00077
00078 if (checkedSrc != src)
00079 delete checkedSrc;
00080 }
00081
00082 }
00083 }
00084 }
00085 }
00086
00087 #endif