34 #ifndef AIMS_PYRAMID_CONVOLUTIONSUBSAMPLER_D_H
35 #define AIMS_PYRAMID_CONVOLUTIONSUBSAMPLER_D_H
67 _func( std::vector<F>( 1, f ) ),
89 _verbose( other._verbose ),
114 namespace convolutionsubsampler {
126 long size2 = ( size << 1 ) - 2;
127 ldiv_t modOp = std::ldiv( i, size2 );
128 return ( modOp.rem < size ) ? modOp.rem : ( size2 - modOp.rem );
137 template <
typename T>
140 long px,
long py,
long pz,
long pt,
144 return vol(
selectCoeff( px, fullsize[0], binf[0] ),
157 template <
typename F>
158 template <
typename OUT,
typename IN>
161 bool doT = in.
getSizeT() > 1 && _dir[3];
162 bool doZ = in.
getSizeZ() > 1 && _dir[2];
163 bool doY = in.
getSizeY() > 1 && _dir[1];
164 bool doX = in.
getSizeX() > 1 && _dir[0];
166 unsigned rX = ( doX ? _factor[0] : 1 );
167 unsigned rY = ( doY ? _factor[1] : 1 );
168 unsigned rZ = ( doZ ? _factor[2] : 1 );
169 unsigned rT = ( doT ? _factor[3] : 1 );
176 std::vector<float> vs( 4, 1. );
187 template <
typename F>
188 template <
typename OUT,
typename IN>
193 std::cout << ( _dir[0] ? std::string(
"X (") +
carto::toString(_factor[0]) + std::string(
") ") :
"" )
194 << ( _dir[1] ? std::string(
"Y (") +
carto::toString(_factor[1]) + std::string(
") ") :
"" )
195 << ( _dir[2] ? std::string(
"Z (") +
carto::toString(_factor[2]) + std::string(
") ") :
"" )
196 << ( _dir[3] ? std::string(
"T (") +
carto::toString(_factor[3]) + std::string(
") ") :
"" )
203 std::vector<int> s = tmp.
getSize();
204 Point4dl binf( b[0], b[2], b[4], b[6] );
205 Point4dl fullsize( s[0] + b[0] + b[1], s[1] + b[2] + b[3],
206 s[2] + b[4] + b[5], s[3] + b[6] + b[7] );
208 const F & fx = _func[0];
209 const F & fy = ( _func.size() > 1 ? _func[1] : _func[0] );
210 const F & fz = ( _func.size() > 2 ? _func[2] : _func[0] );
211 const F & ft = ( _func.size() > 3 ? _func[3] : _func[0] );
213 bool doT = tmp.
getSizeT() > 1 && _dir[3];
214 bool doZ = tmp.
getSizeZ() > 1 && _dir[2];
215 bool doY = tmp.
getSizeY() > 1 && _dir[1];
216 bool doX = tmp.
getSizeX() > 1 && _dir[0];
218 unsigned rX = ( doX ? _factor[0] : 1 );
219 unsigned rY = ( doY ? _factor[1] : 1 );
220 unsigned rZ = ( doZ ? _factor[2] : 1 );
221 unsigned rT = ( doT ? _factor[3] : 1 );
223 long linf = ( doT ? (long)ft.support()[0] : 0 );
224 long lsup = ( doT ? (long)ft.support()[1] : 0 );
225 long kinf = ( doZ ? (long)fz.support()[0] : 0 );
226 long ksup = ( doZ ? (long)fz.support()[1] : 0 );
227 long jinf = ( doY ? (long)fy.support()[0] : 0 );
228 long jsup = ( doY ? (long)fy.support()[1] : 0 );
229 long iinf = ( doX ? (long)fx.support()[0] : 0 );
230 long isup = ( doX ? (long)fx.support()[1] : 0 );
237 for(
long t = 0, ot = 0; ot < out.
getSizeT(); t += rT, ++ot )
238 for(
long z = 0, oz = 0; oz < out.
getSizeZ(); z += rZ, ++oz )
239 for(
long y = 0, oy = 0; oy < out.
getSizeY(); y += rY, ++oy )
240 for(
long x = 0, ox = 0; ox < out.
getSizeX(); x += rX, ++ox )
245 for(
long l = linf; l <= lsup; ++l )
246 for(
long k = kinf; k <= ksup; ++k )
247 for(
long j = jinf; j <= jsup; ++j )
248 for(
long i = iinf; i <= isup; ++i )
250 double ct = doT ? ft( l ) : 1.;
251 double cz = doZ ? fz( k ) : 1.;
252 double cy = doY ? fy( j ) : 1.;
253 double cx = doX ? fx( i ) : 1.;
258 out( ox, oy, oz, ot ) = value;
262 std::cout << std::endl;
271 template <
typename F>
277 template <
typename F>
283 template <
typename F>
286 _func.assign( 4, func );
289 template <
typename F>
290 void ConvolutionSubSampler<F>::setBasisFunction(
const std::vector<F> & func )
295 template <
typename F>
301 template <
typename F>
307 template <
typename F>
310 _dir.assign( 4,
true );
312 for( std::vector<bool>::size_type i = 0; i < dir.size() && i < _dir.size(); ++i )
316 template <
typename F>
325 template <
typename F>
331 template <
typename F>
std::vector< BasisFunction > _func
ConvolutionSubSampler(unsigned r=2)
Constructor / Destructor / Copy.
virtual void print(const bool force=false)
void setProperty(const std::string &, const T &)
bool getProperty(const std::string &, T &) const
std::vector< int > getBorders() const
virtual void copyHeaderFrom(const PropertySet &other)
std::vector< int > getSize() const
const PropertySet & header() const
long mirrorCoeff(long i, long size)
long selectCoeff(long i, long fullsize, long binf)
const T & at(const carto::VolumeRef< T > &vol, long px, long py, long pz, long pt, const Point4dl &fullsize, const Point4dl &binf)
std::string toString(const T &object)
const AlgorithmCaller::LaunchExecution execute