34 #ifndef AIMS_SIGNALFILTER_CONVOLUTIONFILTER_D_H
35 #define AIMS_SIGNALFILTER_CONVOLUTIONFILTER_D_H
50 _func( std::vector<F>( 1, f ) ),
58 ConvolutionFilter<F>::ConvolutionFilter(
const std::vector<F> & f ):
69 _verbose( other._verbose ),
93 namespace convolutionfilter {
105 long size2 = ( size << 1 ) - 2;
106 ldiv_t modOp = std::ldiv( i, size2 );
107 return ( modOp.rem < size ) ? modOp.rem : ( size2 - modOp.rem );
116 template <
typename T>
123 return vol(
selectCoeff( p[0], fullsize[0], binf[0] ),
135 template <
typename F>
136 template <
typename OUT,
typename IN>
143 template <
typename F>
144 template <
typename OUT,
typename IN>
150 std::vector<int> s = tmp.
getSize();
151 Point4dl binf( b[0], b[2], b[4], b[6] );
152 Point4dl fullsize( s[0] + b[0] + b[1], s[1] + b[2] + b[3],
153 s[2] + b[4] + b[5], s[3] + b[6] + b[7] );
155 const F & fx = _func[0];
156 const F & fy = ( _func.size() > 1 ? _func[1] : _func[0] );
157 const F & fz = ( _func.size() > 2 ? _func[2] : _func[0] );
158 const F & ft = ( _func.size() > 3 ? _func[3] : _func[0] );
160 bool doT = tmp.
getSizeT() > 1 && _dir[3];
161 bool doZ = tmp.
getSizeZ() > 1 && _dir[2];
162 bool doY = tmp.
getSizeY() > 1 && _dir[1];
163 bool doX = tmp.
getSizeX() > 1 && _dir[0];
165 long linf = ( doT ? (long)ft.support()[0] : 0 );
166 long lsup = ( doT ? (long)ft.support()[1] : 0 );
167 long kinf = ( doZ ? (long)fz.support()[0] : 0 );
168 long ksup = ( doZ ? (long)fz.support()[1] : 0 );
169 long jinf = ( doY ? (long)fy.support()[0] : 0 );
170 long jsup = ( doY ? (long)fy.support()[1] : 0 );
171 long iinf = ( doX ? (long)fx.support()[0] : 0 );
172 long isup = ( doX ? (long)fx.support()[1] : 0 );
176 std::cout << ( _dir[0] ? std::string(
"X (") +
carto::toString(isup - iinf + 1) + std::string(
") ") :
"" )
177 << ( _dir[1] ? std::string(
"Y (") +
carto::toString(jsup - jinf + 1) + std::string(
") ") :
"" )
178 << ( _dir[2] ? std::string(
"Z (") +
carto::toString(ksup - kinf + 1) + std::string(
") ") :
"" )
179 << ( _dir[3] ? std::string(
"T (") +
carto::toString(lsup - linf + 1) + std::string(
") ") :
"" )
189 for(
long t = 0; t < out.
getSizeT(); ++t )
190 for(
long z = 0; z < out.
getSizeZ(); ++z )
191 for(
long y = 0; y < out.
getSizeY(); ++y )
192 for(
long x = 0; x < out.
getSizeX(); ++x )
198 for(
long l = linf; l <= lsup; ++l )
199 for(
long k = kinf; k <= ksup; ++k )
200 for(
long j = jinf; j <= jsup; ++j )
201 for(
long i = iinf; i <= isup; ++i )
204 double ct = doT ? ft( l ) : 1.;
205 double cz = doZ ? fz( k ) : 1.;
206 double cy = doY ? fy( j ) : 1.;
207 double cx = doX ? fx( i ) : 1.;
211 out( x, y, z, t ) = value;
215 std::cout << std::endl;
224 template <
typename F>
230 template <
typename F>
233 _func.assign( 4, func );
236 template <
typename F>
237 void ConvolutionFilter<F>::setBasisFunction(
const std::vector<F> & func )
242 template <
typename F>
245 _dir.assign( 4,
true );
247 for(
size_t i = 0; (i < dir.size()) && (i < _dir.size()); ++i )
251 template <
typename F>
260 template <
typename F>
266 template <
typename F>
std::vector< BasisFunction > _func
ConvolutionFilter(const BasisFunction &bfunc)
Constructor / Destructor / Copy.
virtual void print(const bool force=false)
std::vector< int > getBorders() const
std::vector< int > getSize() const
long selectCoeff(long i, long fullsize, long binf)
const T & at(const carto::VolumeRef< T > &vol, const Point4dl &p, const Point4dl &fullsize, const Point4dl &binf)
long mirrorCoeff(long i, long size)
std::string toString(const T &object)
const AlgorithmCaller::LaunchExecution execute