STIR  6.2.0
Public Member Functions | List of all members
stir::ArrayFilter1DUsingConvolution< elemT > Class Template Reference

This class implements convolution of a 1D array with an arbitrary (i.e. potentially non-symmetric) kernel. More...

#include "stir/ArrayFilter1DUsingConvolution.h"

Inheritance diagram for stir::ArrayFilter1DUsingConvolution< elemT >:
Inheritance graph
[legend]

Public Member Functions

 ArrayFilter1DUsingConvolution ()
 Construct a trivial filter.
 
 ArrayFilter1DUsingConvolution (const VectorWithOffset< elemT > &filter_kernel, const BoundaryConditions::BC bc=BoundaryConditions::zero)
 Construct the filter given the kernel coefficients. More...
 
bool is_trivial () const override
 checks if the kernel corresponds to a trivial filter operation More...
 
Succeeded get_influencing_indices (IndexRange< 1 > &influencing_indices, const IndexRange< 1 > &output_indices) const override
 
Succeeded get_influenced_indices (IndexRange< 1 > &influenced_indices, const IndexRange< 1 > &input_indices) const override
 
- Public Member Functions inherited from stir::ArrayFunctionObject_2ArgumentImplementation< 1, elemT >
void operator() (Array< num_dimensions, elemT > &array) const override
 in-place modification of array, implemented inline
 
void operator() (Array< num_dimensions, elemT > &out_array, const Array< num_dimensions, elemT > &in_array) const override
 result stored in another array More...
 
- Public Member Functions inherited from stir::ArrayFunctionObject< num_dimensions, elemT >
virtual Succeeded get_influencing_indices (IndexRange< num_dimensions > &influencing_indices, const IndexRange< num_dimensions > &output_indices) const
 sets the range of indices that influences the result in a set of coordinates output_indices More...
 
virtual Succeeded get_influenced_indices (IndexRange< num_dimensions > &influenced_indices, const IndexRange< num_dimensions > &input_indices) const
 sets the range of indices that gets influenced by a set of coordinate input_indices More...
 

Additional Inherited Members

- Protected Member Functions inherited from stir::ArrayFunctionObject_2ArgumentImplementation< 1, elemT >
virtual void do_it (Array< num_dimensions, elemT > &out_array, const Array< num_dimensions, elemT > &in_array) const=0
 

Detailed Description

template<typename elemT>
class stir::ArrayFilter1DUsingConvolution< elemT >

This class implements convolution of a 1D array with an arbitrary (i.e. potentially non-symmetric) kernel.

Convolution is non-periodic:

\[ out_i = \sum_j kernel_j in_{i-j} \]

Note that for most kernels, the above convention means that the zero- index of the kernel corresponds to the peak in the kernel.

By default, zero boundary conditions are used, i.e. elements of the input array that are outside its index range are considered to be 0.

Currently, "constant" boundary conditions are also implemented, i.e. elements of the input array that are outside its index range are considered to the same as the nearest element in the array (i.e. first element on the "left" and last element on the "right").

Example 1
A straightforward low-pass filter, with a symmetric kernel
VectorWithOffset<float> kernel(-1,1);
kernel[-1] = kernel[1] = .25F; kernel[0] = 0.5F;
ArrayFilter1DUsingConvolution<float> lowpass_filter(kernel);
Example 2
A filter which shifts the output 1 index to the right, i.e. $ out_i = in_{i-1}$
VectorWithOffset<float> kernel(1,1);
kernel[1] = 1.F;
ArrayFilter1DUsingConvolution<float> right_shift_filter(kernel);
Warning
1 argument operator() currently leaves the array with the the same index range, i.e. it does not extend it with the kernel size or so.
See also
ArrayFilter1DUsingSymmetricConvolution for an implementation when the kernel is symmetric. (Note: it's not clear if that implementation results in faster execution).
Todo:
implement other boundary conditions

Constructor & Destructor Documentation

◆ ArrayFilter1DUsingConvolution()

template<typename elemT >
stir::ArrayFilter1DUsingConvolution< elemT >::ArrayFilter1DUsingConvolution ( const VectorWithOffset< elemT > &  filter_kernel,
const BoundaryConditions::BC  bc = BoundaryConditions::zero 
)

Construct the filter given the kernel coefficients.

Currently bc has to be BoundaryConditions::zero or BoundaryConditions::constant

Member Function Documentation

◆ is_trivial()

template<typename elemT >
bool stir::ArrayFilter1DUsingConvolution< elemT >::is_trivial ( ) const
overridevirtual

checks if the kernel corresponds to a trivial filter operation

trivial means, either the kernel has 0 length, or length 1 and its only element is 1

Implements stir::ArrayFunctionObject< num_dimensions, elemT >.

References stir::error(), stir::VectorWithOffset< T >::get_length(), stir::VectorWithOffset< T >::get_max_index(), and stir::VectorWithOffset< T >::get_min_index().


The documentation for this class was generated from the following files: