vspline 1.1.0
Generic C++11 Code for Uniform B-Splines
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | List of all members
vspline::fir_filter< in_type, out_type, _math_type > Struct Template Reference

class fir_filter provides the 'solve' routine which convolves a 1D signal with selectable extrapolation. Here, the convolution kernel is applied to the incoming signal and the result is written to the specified output location. Note that this operation can be done in-place, but input and output may also be different. While most of the time this routine will be invoked by class convolve (below), it is also directly used by the specialized code for 1D filtering. Note how we conveniently inherit from the specs class. This also enables us to use an instance of fir_filter or class convolve as specs argument to create further filters with the same arguments. More...

#include <convolve.h>

Inheritance diagram for vspline::fir_filter< in_type, out_type, _math_type >:
vspline::fir_filter_specs

Public Types

typedef vigra::MultiArrayView< 1, in_type > in_buffer_type
 
typedef vigra::MultiArrayView< 1, out_type > out_buffer_type
 
typedef _math_type math_type
 
using allocator_t = typename vspline::allocator_traits< math_type > ::type
 

Public Member Functions

 fir_filter (const fir_filter_specs &specs)
 
int get_support_width () const
 calling code may have to set up buffers with additional space around the actual data to allow filtering code to 'run up' to the data, shedding margin effects in the process. We stay on the safe side and return the width of the whole kernel, which is always sufficient to provide safe runup. More...
 
void solve (const in_buffer_type &input, out_buffer_type &output)
 public 'solve' routine. This is for calls 'from outside', like when this object is used by itself, not as a base class of class convolve below. an extrapolator for the boundary condition code 'bc' (see fir_filter_specs) is made, then the call is delegated to the protected routine below which accepts an extrapolator on top of input and output. More...
 
- Public Member Functions inherited from vspline::fir_filter_specs
 fir_filter_specs (vspline::bc_code _bc, int _ksize, int _headroom, const xlf_type *_kernel)
 

Public Attributes

vigra::MultiArray< 1, math_type, allocator_treactor
 
vigra::MultiArrayView< 1, math_typecircular_buffer
 
vigra::MultiArrayView< 1, math_typekernel_values
 
vigra::MultiArrayView< 1, math_typetail_buffer
 
- Public Attributes inherited from vspline::fir_filter_specs
vspline::bc_code bc
 
int ksize
 
int headroom
 
const xlf_typekernel
 

Static Public Attributes

static const bool is_single_pass { true }
 

Protected Member Functions

void solve (const in_buffer_type &input, out_buffer_type &output, const extrapolator< in_buffer_type > &source)
 protected solve routine taking an extrapolator on top of input and output. This way, the derived class (class convolve) can maintain an extrapolator fixed to it's buffer and reuse it for subsequent calls to this routine. we use the following strategy: More...
 

Detailed Description

template<typename in_type, typename out_type = in_type, typename _math_type = out_type>
struct vspline::fir_filter< in_type, out_type, _math_type >

class fir_filter provides the 'solve' routine which convolves a 1D signal with selectable extrapolation. Here, the convolution kernel is applied to the incoming signal and the result is written to the specified output location. Note that this operation can be done in-place, but input and output may also be different. While most of the time this routine will be invoked by class convolve (below), it is also directly used by the specialized code for 1D filtering. Note how we conveniently inherit from the specs class. This also enables us to use an instance of fir_filter or class convolve as specs argument to create further filters with the same arguments.

Definition at line 132 of file convolve.h.

Member Typedef Documentation

◆ allocator_t

template<typename in_type , typename out_type = in_type, typename _math_type = out_type>
using vspline::fir_filter< in_type, out_type, _math_type >::allocator_t = typename vspline::allocator_traits < math_type > :: type

Definition at line 154 of file convolve.h.

◆ in_buffer_type

template<typename in_type , typename out_type = in_type, typename _math_type = out_type>
typedef vigra::MultiArrayView< 1 , in_type > vspline::fir_filter< in_type, out_type, _math_type >::in_buffer_type

Definition at line 139 of file convolve.h.

◆ math_type

template<typename in_type , typename out_type = in_type, typename _math_type = out_type>
typedef _math_type vspline::fir_filter< in_type, out_type, _math_type >::math_type

Definition at line 141 of file convolve.h.

◆ out_buffer_type

template<typename in_type , typename out_type = in_type, typename _math_type = out_type>
typedef vigra::MultiArrayView< 1 , out_type > vspline::fir_filter< in_type, out_type, _math_type >::out_buffer_type

Definition at line 140 of file convolve.h.

Constructor & Destructor Documentation

◆ fir_filter()

template<typename in_type , typename out_type = in_type, typename _math_type = out_type>
vspline::fir_filter< in_type, out_type, _math_type >::fir_filter ( const fir_filter_specs specs)
inline

Definition at line 163 of file convolve.h.

Member Function Documentation

◆ get_support_width()

template<typename in_type , typename out_type = in_type, typename _math_type = out_type>
int vspline::fir_filter< in_type, out_type, _math_type >::get_support_width ( ) const
inline

calling code may have to set up buffers with additional space around the actual data to allow filtering code to 'run up' to the data, shedding margin effects in the process. We stay on the safe side and return the width of the whole kernel, which is always sufficient to provide safe runup.

Definition at line 187 of file convolve.h.

◆ solve() [1/2]

template<typename in_type , typename out_type = in_type, typename _math_type = out_type>
void vspline::fir_filter< in_type, out_type, _math_type >::solve ( const in_buffer_type input,
out_buffer_type output 
)
inline

public 'solve' routine. This is for calls 'from outside', like when this object is used by itself, not as a base class of class convolve below. an extrapolator for the boundary condition code 'bc' (see fir_filter_specs) is made, then the call is delegated to the protected routine below which accepts an extrapolator on top of input and output.

Definition at line 200 of file convolve.h.

◆ solve() [2/2]

template<typename in_type , typename out_type = in_type, typename _math_type = out_type>
void vspline::fir_filter< in_type, out_type, _math_type >::solve ( const in_buffer_type input,
out_buffer_type output,
const extrapolator< in_buffer_type > &  source 
)
inlineprotected

protected solve routine taking an extrapolator on top of input and output. This way, the derived class (class convolve) can maintain an extrapolator fixed to it's buffer and reuse it for subsequent calls to this routine. we use the following strategy:

  • keep a small circular buffer as large as the kernel
  • have two kernels concatenated in another buffer
  • by pointing into the concatenated kernels, we can always have ksize kernel values in sequence so that this sequence is correct for the values in the circular buffer. this strategy avoids conditionals as best as possible and should be easy to optimize. the actual code is a bit more complex to account for the fact that at the beginning and end of the data, a few extrapolated values are used. The central loop can directly read from input without using the extrapolator, which is most efficient.

Definition at line 227 of file convolve.h.

Member Data Documentation

◆ circular_buffer

template<typename in_type , typename out_type = in_type, typename _math_type = out_type>
vigra::MultiArrayView< 1 , math_type > vspline::fir_filter< in_type, out_type, _math_type >::circular_buffer

Definition at line 158 of file convolve.h.

◆ is_single_pass

template<typename in_type , typename out_type = in_type, typename _math_type = out_type>
const bool vspline::fir_filter< in_type, out_type, _math_type >::is_single_pass { true }
static

Definition at line 137 of file convolve.h.

◆ kernel_values

template<typename in_type , typename out_type = in_type, typename _math_type = out_type>
vigra::MultiArrayView< 1 , math_type > vspline::fir_filter< in_type, out_type, _math_type >::kernel_values

Definition at line 159 of file convolve.h.

◆ reactor

template<typename in_type , typename out_type = in_type, typename _math_type = out_type>
vigra::MultiArray< 1 , math_type , allocator_t > vspline::fir_filter< in_type, out_type, _math_type >::reactor

Definition at line 157 of file convolve.h.

◆ tail_buffer

template<typename in_type , typename out_type = in_type, typename _math_type = out_type>
vigra::MultiArrayView< 1 , math_type > vspline::fir_filter< in_type, out_type, _math_type >::tail_buffer

Definition at line 160 of file convolve.h.


The documentation for this struct was generated from the following file: