34 #ifndef AIMS_INTERPOLATION_SPLINEPYRAMID_D_H
35 #define AIMS_INTERPOLATION_SPLINEPYRAMID_D_H
71 double at(
int x )
const;
89 if( n == 1 && m == 2 )
99 if( n == 3 && m == 2 )
113 _support( other._support ),
114 _values( other._values )
165 double at(
int x )
const;
178 _values.push_back( 1. / 5040. );
179 _values.push_back( 120. / 5040. );
180 _values.push_back( 1191. / 5040. );
181 _values.push_back( 2416. / 5040. );
182 _values.push_back( 1191. / 5040. );
183 _values.push_back( 120. / 5040. );
184 _values.push_back( 1. / 5040. );
189 if( n == 1 && m == 2 )
192 _values.push_back( .5 / 5040. );
193 _values.push_back( 61. / 5040. );
194 _values.push_back( 716. / 5040. );
195 _values.push_back( 2459. / 5040. );
196 _values.push_back( 3607. / 5040. );
197 _values.push_back( 2459. / 5040. );
198 _values.push_back( 716. / 5040. );
199 _values.push_back( 61. / 5040. );
200 _values.push_back( .5 / 5040. );
205 if( n == 3 && m == 2 )
208 _values.push_back( 1. / 40320. );
209 _values.push_back( 124. / 40320. );
210 _values.push_back( 1677. / 40320. );
211 _values.push_back( 7904. / 40320. );
212 _values.push_back( 18482. / 40320. );
213 _values.push_back( 24264. / 40320. );
214 _values.push_back( 18482. / 40320. );
215 _values.push_back( 7904. / 40320. );
216 _values.push_back( 1677. / 40320. );
217 _values.push_back( 124. / 40320. );
218 _values.push_back( 1. / 40320. );
226 _support( other._support ),
227 _values( other._values )
273 _factor( 1,
Point4du(factor, factor, factor, factor) ),
282 _factor( 1, factor ),
299 _order( other._order ),
300 _factor( other._factor ),
302 _verbose( other._verbose )
329 std::vector<Point4du> factors;
336 unsigned nlevels = 0;
337 Point4dl level_size( size[0], size[1], size[2], size[3] );
342 for(
int i = 0; i < 4; ++i )
345 level_size[i] /=
_factor[0][i];
346 if( level_size[i] == 1 )
351 factors.assign( nlevels,
_factor[0] );
354 Point4dl level_size( size[0], size[1], size[2], size[3] );
355 for( std::vector<Point4du>::iterator f = factors.begin();
356 f != factors.end(); ++f )
358 for(
int i = 0; i < 4; ++i )
362 if( level_size[i] / (*f)[i] == 0 )
365 level_size[i] /= (*f)[i];
372 factors.erase( f, factors.end() );
382 template <
typename T>
386 std::vector<carto::VolumeRef<double> > pyramid;
387 pyramid.reserve( factors.size() + 1 );
388 std::vector<InterpolatedVolume> interpol( factors.size() + 1 );
394 std::cout <<
"Copy root level spline coefficients... " << std::endl;
395 pyramid.push_back( carto::copy<double, T>(vol) );
400 std::cout <<
"Compute root level spline coefficients from image... " << std::endl;
401 pyramid.push_back( carto::copy<double, T>(vol) );
404 std::cout <<
"BSpline inverse filter: " << std::flush;
408 invfilter.
execute( pyramid[0],
true );
410 interpol[0].setCoeff( pyramid[0] );
414 std::cout <<
"Compute dual coefficients for level 1... " << std::endl;
417 std::cout <<
"Moving average * Direct BSpline filter/subsampling: " << std::flush;
418 std::vector<DiscreteUB> bufunc;
427 pyramid.push_back( busub.
execute<
double,
double>( pyramid[0] ) );
428 pyramid[1] /= factors[0][0] * factors[0][1] * factors[0][2] * factors[0][3];
431 std::vector<Point4du>::iterator f = ( factors.begin() == factors.end()
433 : ++(factors.begin()) );
435 for( ; f != factors.end(); ++f, ++l )
438 std::cout <<
"Compute dual coefficients for level " << l <<
"... " << std::endl;
441 std::cout <<
"Moving average filter/subsampling: " << std::flush;
442 std::vector<DiscreteU> bfunc;
454 pyramid.push_back( sub.
execute<
double,
double>( pyramid[l-1] ) );
455 pyramid[l] /= (*f)[0] * (*f)[1] * (*f)[2] * (*f)[3];
456 interpol[l].setCoeff( pyramid[l] );
459 std::cout <<
"Compute spline coefficients for level " << l-1 <<
"... " << std::endl;
461 std::cout <<
"BSpline inverse filter: " << std::flush;
465 invfilter.
execute( pyramid[l-1],
true );
467 std::cout << std::endl;
468 interpol[l-1].setCoeff( pyramid[l-1] );
473 std::cout <<
"Compute spline coefficients for level " << l-1 <<
"... " << std::endl;
475 std::cout <<
"BSpline inverse filter: " << std::flush;
479 invfilter.
execute( pyramid[l-1],
true );
481 std::cout << std::endl;
482 interpol[l-1].setCoeff( pyramid[l-1] );
529 _dir.assign( 4,
true );
531 for( std::vector<bool>::size_type i = 0; i < dir.size() && i <
_dir.size(); ++i )
559 template <
typename T>
570 for(
size_t i = 0; i <
pyramid.size(); ++i )
carto::VolumeRef< OUT > execute(const carto::VolumeRef< IN > &in) const
Execution.
void setDirections(const std::vector< bool > &dir)
void setVerbose(int verbose=1)
double operator()(int x) const
std::vector< double > _values
DiscreteUB(unsigned m, unsigned n)
DiscreteUB & operator=(const DiscreteUB &other)
const Point2di & support() const
DiscreteU & operator=(const DiscreteU &other)
std::vector< double > _values
DiscreteU(unsigned m, unsigned n)
double operator()(int x) const
const Point2di & support() const
virtual void setDirections(const std::vector< bool > &dir)
carto::VolumeRef< double > execute(const carto::VolumeRef< T > &in) const
Execution.
virtual void setVerbose(int verbose=1)
Verbosity level.
Spline interpolation of volumes with simple accessors to interpolated values.
This filter uses an inverse B-Spline convolution function to transform a discrete signal to its splin...
The method follows that of Under, Aldroubi & Eden, "The L2 Polynomial Spline Pyramid" in IEEE Transac...
void setDirections(const std::vector< bool > &dir)
void setFactor(unsigned r)
SplinePyramidBuilder(unsigned factor=2, unsigned spline_order=3)
Constructors / Destructors / Copy.
unsigned order() const
Parameters.
const std::vector< bool > & directions() const
void setVerbose(int verbose=1)
void setOrder(unsigned n)
SplinePyramid execute(const carto::VolumeRef< T > &vol, bool is_coeff=false) const
Execution.
virtual ~SplinePyramidBuilder()
std::vector< Point4du > computeFactors(const std::vector< int > &size) const
Execution.
std::vector< Point4du > _factor
const std::vector< Point4du > & factor() const
SplinePyramidBuilder & operator=(const SplinePyramidBuilder &other)
Pyramid of Interpolated Volumes.
const std::vector< InterpolatedVolume > & pyramid() const
Change pyramid.
SplinePyramid(const std::vector< InterpolatedVolume > &pyramid=std::vector< InterpolatedVolume >())
Constructors / Destructors / Copy.
std::vector< InterpolatedVolume > _pyramid
std::vector< int > getSize() const