143#ifndef VSPLINE_BSPLINE_H
144#define VSPLINE_BSPLINE_H
190template <
unsigned int _dimension >
199 typedef vigra::TinyVector < std::ptrdiff_t , dimension >
shape_type ;
203 typedef typename vigra::TinyVector < bc_code , dimension >
bcv_type ;
207 typedef typename vigra::TinyVector < xlf_type , dimension >
limit_type ;
302 int support = spline_degree / 2 ;
339 else if ( spline_degree & 1 )
352 int support = spline_degree / 2 ;
372 if ( ! ( spline_degree & 1 ) )
392 if ( spline_degree & 1 )
440 template <
typename = std::enable_if < _dimension == 1 > >
496template <
class _value_type ,
unsigned int _dimension >
504 enum {
channels = ExpandElementResult < value_type >::size } ;
508 typedef typename ExpandElementResult < value_type >::type
ele_type ;
535 typedef vigra::MultiArray < dimension , value_type >
array_type ;
539 typedef vigra::MultiArrayView < dimension , value_type >
view_type ;
561 std::shared_ptr < array_type > _p_coeffs ;
635 int _spline_degree = 3 ,
657 if ( _space.hasData() )
667 throw shape_mismatch (
"the intended container shape does not fit into the shape of the storage space passed in" ) ;
677 _p_coeffs = std::make_shared < array_type >() ;
708 template <
typename = std::enable_if < _dimension == 1 > >
710 int _spline_degree = 3 ,
716 :
bspline ( vigra::TinyVector < long , 1 > ( _core_shape ) ,
739 MultiArrayView < dimension , ele_type >
740 channel_container (
container.shape() , stride , base ) ;
749 auto headroom =
left_frame[0] - std_left_frame_size[0] ;
811 template <
class math_ele_type
812 =
typename vigra::NumericTraits < ele_type > :: RealPromote ,
852 template <
typename T ,
853 typename math_ele_type
854 =
typename vigra::NumericTraits
855 <
typename vigra::PromoteTraits
859 void prefilter (
const vigra::MultiArrayView < dimension , T > & data ,
872 if ( data.shape() !=
core.shape() )
874 (
"when passing data to prefilter, they have to have precisely the core's shape" ) ;
929 if ( new_degree < 0 )
934 if ( allLessEqual ( new_left_brace ,
left_frame )
935 && allLessEqual ( new_right_brace ,
right_frame ) )
967 osr <<
"dimension:................... " << bsp.
dimension << std::endl ;
968 osr <<
"degree:...................... " << bsp.
spline_degree << std::endl ;
969 osr <<
"boundary conditions:......... " ;
970 for (
auto bc : bsp.
bcv )
973 osr <<
"shape of container array:.... " << bsp.
container.shape() << std::endl ;
974 osr <<
"shape of core:............... " << bsp.
core.shape() << std::endl ;
975 osr <<
"left frame:.................. " << bsp.
left_frame << std::endl ;
976 osr <<
"right frame:................. " << bsp.
right_frame << std::endl ;
977 osr <<
"ownership of data:........... " ;
978 osr << ( bsp._p_coeffs->hasData()
979 ?
"bspline object owns data"
980 :
"data are owned externally" ) << std::endl ;
981 osr <<
"container base adress:....... " << bsp.
container.data() << std::endl ;
982 osr <<
"core base adress:............ " << bsp.
core.data() << std::endl ;
983 osr <<
"prefiltered:................. "
984 << ( bsp.
prefiltered ?
"yes" :
"no" ) << std::endl ;
994template <
class spline_type ,
typename rc_type >
1000template <
class spline_type >
This file provides code for 'bracing' a b-spline's coefficient array.
void prefilter(const vigra::MultiArrayView< dimension, in_value_type > &input, vigra::MultiArrayView< dimension, out_value_type > &output, vigra::TinyVector< bc_code, static_cast< int >(dimension) > bcv, int degree, xlf_type tolerance=std::numeric_limits< math_ele_type > ::epsilon(), xlf_type boost=xlf_type(1), int njobs=default_njobs)
'prefilter' handles b-spline prefiltering for the whole range of acceptable input and output....
typename vigra::ExpandElementResult< T > ::type ET
using definition for the 'elementary type' of a type via vigra's ExpandElementResult mechanism....
void apply(const unary_functor_type &ev, vigra::MultiArrayView< dimension, typename unary_functor_type::out_type > &output, int njobs=vspline::default_njobs, vspline::atomic< bool > *p_cancel=0)
we code 'apply' as a special variant of 'transform' where the output is also used as input,...
vspline::canonical_type< rc_type, spline_type::dimension > bspl_coordinate_type
using declaration for a coordinate suitable for bspline, given elementary type rc_type....
typename std::conditional< N==1, ET< T >, vigra::TinyVector< ET< T >, N > > ::type canonical_type
produce the 'canonical type' for a given type T. If T is single-channel, this will be the elementary ...
const std::string bc_name[]
bc_name is for diagnostic output of bc codes
bc_code
This enumeration is used for codes connected to boundary conditions. There are two aspects to boundar...
typename spline_type::value_type bspl_value_type
using declaration for a bspline's value type
Code to create the coefficient array for a b-spline.
class bracer encodes the entire bracing process. Note that contrary to my initial implementation,...
struct bspline is the object in vspline holding b-spline coefficients. In a way, the b-spline 'is' it...
xlf_type lower_limit(const int &axis) const
vigra::TinyVector< std::ptrdiff_t, dimension > shape_type
type of a multidimensional index type
bspline_base(shape_type _core_shape, int _spline_degree, bcv_type _bcv, xlf_type _tolerance, int headroom)
The constructor sets up all metrics of the spline from the basic properties given for the spline....
xlf_type upper_limit(const int &axis) const
static shape_type get_container_shape(int spline_degree, bcv_type bcv, shape_type core_shape, int headroom)
convenience method to caculate the shape of a container array needed to hold the coefficients of a sp...
vigra::TinyVector< bc_code, dimension > bcv_type
nD type for one boundary condition per axis
const shape_type container_shape
static shape_type get_right_brace_size(int spline_degree, bcv_type bcv)
static long get_container_shape(int spline_degree, vspline::bc_code bc, long core_shape, int headroom)
variant for 1D splines. This variant accepts the shape as a plain long, rather than requiring a TinyV...
vigra::TinyVector< xlf_type, dimension > limit_type
nD type for one limit condition per axis
limit_type lower_limit() const
static xlf_type lower_limit(const bc_code &bc)
lower_limit returns the lower bound of the spline's defined range. This is usually 0....
const shape_type right_frame
static xlf_type upper_limit(const std::size_t &extent, const bc_code &bc)
upper_limit returns the upper bound of the spline's defined range. This is normally M - 1 if the shap...
const shape_type left_frame
limit_type upper_limit() const
const shape_type core_shape
static shape_type get_left_brace_size(int spline_degree, bcv_type bcv)
get_left_brace_size and get_right_brace_size calculate the size of the brace vspline puts around the ...
class bspline now builds on class bspline_base, adding coefficient storage, while bspline_base provid...
ExpandElementResult< value_type >::type ele_type
elementary type of value_type, like float or double
friend std::ostream & operator<<(std::ostream &osr, const bspline &bsp)
helper function to pretty-print a bspline object to an ostream
vigra::TinyVector< std::ptrdiff_t, dimension > shape_type
type of a multidimensional index type
bspline< value_type, dimension > spline_type
the type of 'this' bspline and of a 'channel view'
void prefilter(vspline::xlf_type boost=vspline::xlf_type(1), int njobs=vspline::default_njobs)
prefilter converts the knot point data in the 'core' area into b-spline coefficients....
const shape_type container_shape
static shape_type get_right_brace_size(int spline_degree, bcv_type bcv)
vigra::MultiArrayView< dimension, value_type > view_type
data are read and written to vigra MultiArrayViews:
void prefilter(const vigra::MultiArrayView< dimension, T > &data, vspline::xlf_type boost=vspline::xlf_type(1), int njobs=vspline::default_njobs)
If data are passed in, they have to have precisely the shape we have set up in core (_core_shape pass...
void brace(int axis=-1)
if the spline coefficients are already known, they obviously don't need to be prefiltered....
bspline(long _core_shape, int _spline_degree=3, bc_code _bc=MIRROR, xlf_type _tolerance=-1.0, int headroom=0, view_type _space=view_type())
overloaded constructor for 1D splines. This is useful because if we don't provide it,...
vigra::MultiArray< dimension, value_type > array_type
if the coefficients are owned, an array of this type holds the data:
const shape_type right_frame
bspline(shape_type _core_shape, int _spline_degree=3, bcv_type _bcv=bcv_type(MIRROR), xlf_type _tolerance=-1.0, int headroom=0, view_type _space=view_type())
construct a bspline object with appropriate storage space to contain and process an array of knot poi...
bspline< ele_type, dimension > channel_view_type
bool shiftable(int d) const
'shift' will change the interpretation of the data in a bspline object. d is taken as a difference to...
const shape_type left_frame
channel_view_type get_channel_view(const int &channel)
get a bspline object for a single channel of the data. This is lightweight and requires the viewed da...
static shape_type get_left_brace_size(int spline_degree, bcv_type bcv)
get_left_brace_size and get_right_brace_size calculate the size of the brace vspline puts around the ...
bool prefiltered
boolean flag indicating whether the coefficients were prefiltered or not. This must be taken with a g...
bool shift(int d)
shift() actually changes the interpretation of the data. The data will be taken to be coefficients of...
bspline_base< _dimension > base_type
shape mismatch is the exception which is thrown if the shapes of an input array and an output array d...
with the definition of 'simd_traits', we can proceed to implement 'vector_traits': struct vector_trai...