This section describes the Convolution class provided by VSIPL++.
Applying a convolution object on a view performs a convolution on the view. Convolution supports different computations, depending on the element type and dimensionalities of the kernel, input and output views.
template <template <typename, typename> class ConstViewT,
symmetry_type Symm,
support_region_type Supp,
typename T,
unsigned N_times = 0,
alg_hint_type A_hint = alg_time>
class Convolution;Template parameters
ConstViewTThe convolution dimensionality: const_Vector for 1D convolutions; const_Matrix for 2D convolutions.
SymmThe symmetry of the kernel. See symmetry_type (section 2.7.10).
SuppThe support region of the convolution algorithm. See support_region_type (section 2.7.9).
TThe type of the elements in the views.
N_timesThe expected number of times this object will be used. This is a
hint how much effort to spend on upfront optimization. A value of
0 stands for infinity, and thus results in the most
effort.
A_hintOne of alg_time,
alg_space, or alg_none. This
indicates how the implementation should optimize its computation or
resource use. See alg_hint_type (section 2.7.1).
Construct a 1D object
template <unspecified> Convolution(const_Vector<T, unspecified> filter_coeffs, Domain<1> const& input_size, length_type decimation = 1);
Construct a 2D object
template <unspecified> Convolution(const_Matrix<T, unspecified> filter_coeffs, Domain<2> const& input_size, length_type decimation = 1);
Description: Create a Convolution object of the given kernel view,
input size, and decimation. The first version is available when the class's
ConstViewT template parameter is const_Vector<T,
unspecified>; the second when it is
const_Matrix<T,unspecified>.
template <unspecified> Vector<T, unspecified> operator()( const_Vector<T, unspecified> in, Vector<T, unspecified> out);
Description: Calls the Convolution on the given input vector. This version is
available only when the class's ConstViewT template parameter
is const_Vector<T, unspecified>.
Result: The result view is stored into the out argument,
and is returned as return-value for convenience, too.
template <unspecified> Matrix<T, unspecified> operator()( const_Matrix<T, unspecified> in, Matrix<T, unspecified> out);
Description: Calls the Convolution on the given input matrix. This version is
available only when the class's ConstViewT template parameter
is const_Matrix<T, unspecified>.
Result: The result view is stored into the out argument,
and is returned as return-value for convenience, too.
// Declare a vector of kernel coefficients. Vector<float> coeff(5); ... // Initialize the coefficients. // Declare a convolution object. Convolution<const_Vector, nonsym, support_min, float> conv(coeff, Domain<1>(100), 1); // Declare the input vector. Vector<float> in(100); ... // Initialize the input vector. // Declare the output vector. Vector<float> out(96); // Perform the convolution of the input into the output. conv(in, out);
This section describes the Correlation class provided by VSIPL++.
Applying a correlation object on a view performs a correlation on the view. Correlation supports different computations, depending on the element type and dimensionalities of the kernel, input and output views.
template <template <typename, typename> class ConstViewT,
support_region_type Supp,
typename T,
unsigned N_times = 0,
alg_hint_type A_hint = alg_time>
class Correlation;Template parameters
ConstViewTThe correlation dimensionality: const_Vector for 1D correlations; const_Matrix for 2D correlations.
SuppThe support region of the correlation algorithm. See support_region_type (section 2.7.9).
TThe type of the elements in the views.
N_timesThe expected number of times this object will be used. This is a
hint how much effort to spend on upfront optimization. A value of
0 stands for infinity, and thus results in the most
effort.
A_hintOne of alg_time,
alg_space, or alg_none. This
indicates how the implementation should optimize its computation or
resource use. See alg_hint_type xx (section 2.7.1).
Construct a 1D object
Correlation(Domain<1> const& ref_size,
Domain<1> const& input_size);Construct a 2D object
Correlation(Domain<2> const& ref_size,
Domain<2> const& input_size);Description: Creates a Correlation object with the given kernel size
and input size. The first version is available when the class's
ConstViewT template parameter is const_Vector<T,
unspecified>; the second when it is
const_Matrix<T,unspecified>.
template <unspecified> Vector<T, unspecified> operator()( bias_type bias, const_Vector<T, unspecified> ref, const_Vector<T, unspecified> in, Vector<T, unspecified> out);
Description: Calls the Correlation on the given kernel, input and output vectors.
This version is available only when the class's ConstViewT
template parameter is const_Vector<T,
unspecified>. The parameter bias must
be a member of the enumeration bias_type. See (section 2.7.2).
Result: The result view is stored into the out argument,
and is returned as return-value for convenience, too.
template <unspecified> Matrix<T, unspecified> operator()( bias_type bias, const_Matrix<T, unspecified> ref, const_Matrix<T, unspecified> in, Matrix<T, unspecified> out);
Description: Calls the Correlation on the given kernel, input and output matrices.
This version is available only when the class's ConstViewT
template parameter is const_Matrix<T,
unspecified>. The parameter bias must
be a member of the enumeration bias_type. See (section 2.7.2).
Result: The result view is stored into the out argument,
and is returned as return-value for convenience, too.
// Declare a correlation object.
Correlation<const_Vector, support_min, float>
corr(Domain<1>(5), Domain<1>(100));
// Declare a vector of kernel items.
Vector<float> kernel(5);
... // Initialize the kernel.
// Declare the input vector.
Vector<float> in(100);
... // Initialize the input vector.
// Declare the output vector.
Vector<float> out(96);
// Perform the correlation of the input into the output.
corr(biased, kernel, in, out);This section describes the Fir class provided by VSIPL++.
Applying a Fir object to a view performs a FIR filter on the view.
template <typename T,
symmetry_type S = nonsym,
obj_state C = state_save,
unsigned N = 0,
alg_hint_type H = alg_time>
class Fir;Template parameters
The type of the elements in the views.
The symmetry of the kernel. See symmetry_type (section 2.7.10).
state_no_save or state_save.
An Fir object can maintain state between invocations of its
call operator. See obj_state (section 2.7.4).
The expected number of times this object will be used. This is a hint how much effort to spend on upfront optimization. A value of 0 stands for infinity, and thus results in the most effort.
One of alg_time,
alg_space, or alg_none. This
indicates how the implementation should optimize its computation or
resource use. See alg_hint_type (section 2.7.1).
template <unspecified> Fir( const_Vector<T,unspecified> kernel, length_type input_size, length_type decimation = 1)
Description: Construct an Fir object with a vector of kernel coefficients and the indicated size of input vector and decimation.
Fir(Fir const &fir)
Description: Construct a new Fir object from an existing one..
length_type kernel_size() length_type filter_order() length_type input_size() length_type output_size() length_type decimation() obj_state continuous_filtering()
Description: Report the various attributes of this Fir object.
template <unspecified> length_type operator()( const_Vector<T, unspecified> in, Vector<T, unspecified> out )
Description: Apply the Fir object to the vector in
and write results in the vector out. The length of the
output vector is returned.
// Declare the kernel vector. Vector<float> kernel(5); ... // Initialize the kernel vector. // Declare an FIR object. Fir<float,nonsym,state_save> fir(kernel, 100, 1); // Declare the input vector. Vector<float> in(100); ... // Initialize the input vector. // Declare the output vector. Vector<float> out(96); // Perform the FIR filter on the input into the output. fir(in, out);
Applying an FFT object on a view performs a single Fast Fourier Transform on the entire view. Fft supports different computations, dependent on the input element type, output element type, a specified direction or a special dimension, and the dimensionalities of the input and output views.
template <template <typename, typename> class ViewT,
typename InputT,
typename OutputT,
int SD = 0,
return_mechanism_type ReturnMechanism = by_value,
unsigned Number = 0,
alg_hint_type Hint = alg_time>
class Fft;Template parameters
Used to indicate the FFT dimensionality:
const_Vector for 1D FFTs, const_Matrix
for 2D FFTs, and const_Tensor for 3D FFTs.
The input and output value-types of the Fourier transform, respectively. For a complex transform, both types need to be identical. For a real transform, one of them is complex, the other real.
The special dimension / direction. In case of a real FFT, its value indicates which dimension has different input and output sizes. In case of a complex FFT, its value indicates whether to perform a forward or inverse transform.
The return-mechanism-type indicates whether to return the output-view by-value or by-reference.
The expected number of times this object will be used. This is a
hint how much effort to spend on upfront optimization. A value of
0 stands for infinity, and thus results in the most
effort.
One of alg_time,
alg_space, or alg_none. This
indicates how the implementation should optimize its computation or
resource use.
FFT parameters should fulfill the following requirements. Input and output sizes are specified during construction, the other parameters are template arguments.
| View | input-type / output-type | SD | input size | output size |
|---|---|---|---|---|
| Vector | complex<T> /
complex<T> | fft_fwd | M | M |
complex<T> /
complex<T> | fft_inv | M | M | |
T /
complex<T> | 0 | M | M/2 + 1 | |
complex<T> /
T | 0 | M/2 + 1 | M | |
| Matrix | complex<T> /
complex<T> | fft_fwd | MxN | MxN |
complex<T> /
complex<T> | fft_inv | MxN | MxN | |
T /
complex<T> | 0 | MxN | Mx(N/2 + 1) | |
T /
complex<T> | 1 | MxN | (M/2 + 1)xN | |
complex<T> /
T | 0 | Mx(N/2 + 1) | MxN | |
complex<T> /
T | 1 | (M/2 + 1)xN | MxN | |
| Tensor | complex<T> /
complex<T> | fft_fwd | MxNxP | MxNxP |
complex<T> /
complex<T> | fft_inv | MxNxP | MxNxP | |
T /
complex<T> | 0 | MxNxP | MxNx(P/2 +
1) | |
T /
complex<T> | 1 | MxNxP | Mx(N/2 +
1)xP | |
T /
complex<T> | 2 | MxNxP | MxNx(P/2 +
1) | |
complex<T> /
T | 0 | MxNx(P/2 +
1) | MxNxP | |
complex<T> /
T | 1 | Mx(N/2 +
1)xP | MxNxP | |
complex<T> /
T | 2 | MxNx(P/2 +
1) | MxNxP |
Fft(Domain<dim> const& dom, scalar_type scale);
Description: Creates an Fft object of the given size, with the given scaling factor.
Requirements: dim is the Fft dimensionality.
Domain<dim> const& input_size() const; Domain<dim> const& output_size() const; scalar_type scale() const; bool forward() const;
Description: Report the various attributes of this Fft object.
forward() returns true for a forward transform, false
otherwise.
template <class ViewT>
<undefined> operator()(ViewT in);Description: Calls the Fft on the given input, out-of-place.
Requirements: This operator is available for
ReturnMechanismType=by_value only. ViewT has to
obey they above requirements for type and dimensions.
Result: Returns a new view containing the output.
template <class InViewT, class OutViewT> OutViewT operator()(InViewT in, OutViewT out);
Description: Calls the Fft on the given input, out-of-place
Requirements: This operator is available for
ReturnMechanismType=by_reference only. InViewT
and OutViewT have to obey the above requirements for type and
dimensions.
Result: The result view is stored into the out argument,
and is returned as return-value for convenience, too.
template <class ViewT> ViewT operator()(ViewT inout);
Description: Calls the Fft on the given input, in-place.
Requirements: This operator is available only for complex FFT objects, with
ReturnMechanismType=by_reference. ViewT has to
obey the above requirements for type and dimensions.
Result: The result is stored in-place into the inout
view, and is also returned as return-value for convenience
Applying an Fftm object on a Matrix performs multiple fast Fourier transforms on the rows or columns of a Matrix. A Multiple FFT treats a matrix as a collection of either rows or columns and applies an FFT to each row or column.
template <typename InputT,
typename OutputT,
int A = row,
int D = fft_fwd,
return_mechanism_type ReturnMechanism = by_value,
unsigned Number = 0,
alg_hint_type Hint = alg_time>
class Fftm;Template parameters
The input and output value-types of the Fourier transform, respectively. For a complex transform, both types need to be identical. For a real transform, one of them is complex, the other real.
The dimension along which to apply the Ffts.
The direction of the Ffts, either fft_fwd or
fft_inv.
The return-mechanism-type indicates whether to return the output-view by-value or by-reference.
The expected number of times this object will be used. This is a
hint how much effort to spend on upfront optimization. A value of
0 stands for infinity, and thus results in the most
effort.
A alg_hint_type (section 2.7.1), indicating how the implementation should optimize its computation or resource use.
FFTM parameters should fulfill the following requirements. Input and output sizes are specified during construction, the other parameters are template arguments.
| input-type / output-type | axis | direction | input size | output size |
|---|---|---|---|---|
complex<T> /
complex<T> | 0 or 1 | fft_fwd | MxN | MxN |
complex<T> /
complex<T> | 0 or 1 | fft_inv | MxN | MxN |
T /
complex<T> | 0 | fft_fwd | MxN | Mx(N/2 + 1) |
T /
complex<T> | 1 | fft_fwd | MxN | (M/2 + 1)xN |
complex<T> /
T | 0 | fft_inv | Mx(N/2 + 1) | MxN |
complex<T> /
T | 1 | fft_inv | (M/2 + 1)xN | MxN |
Fftm(Domain<2> const& dom, scalar_type scale);
Description: Creates an Fftm object of the given size, with the given scaling factor.
Domain<2> const& input_size() const; Domain<2> const& output_size() const; scalar_type scale() const; bool forward() const;
Description: Report the various attributes of this Fftm object.
forward() returns true for a forward transform, false
otherwise.
template <class MatrixT>
<undefined> operator()(MatrixT in);Description: Calls the Fftm on the given input, out-of-place.
Requirements: This operator is available for
ReturnMechanismType=by_value only. MatrixT has
to obey the above requirements for type and dimensions.
Result: Returns a new matrix containing the output.
template <class InMatrixT, class OutMatrixT> OutMatrixT operator()(InMatrixT in, OutMatrixT out);
Description: Calls the Fftm on the given input, out-of-place.
Requirements: This operator is available for
ReturnMechanismType=by_reference only. InMatrixT
and OutMatrixT have to obey the above requirements for type
and dimensions.
Result: The result matrix is stored into the out
argument, and is returned as return-value for convenience, too.
template <class MatrixT> MatrixT operator()(MatrixT inout);
Description: Calls the Fftm on the given input, in-place.
Requirements: This operator is available only for complex FFTM objects, with
ReturnMechanismType=by_reference. MatrixT has to
obey the above requirements for type and dimensions.
Result: The result is stored in-place into the inout
matrix, and is also returned as return-value for convenience.
This section describes the Histogram class provided by VSIPL++.
Applying a histogram object to a view computes a histogram of the view. Histogram supports different computations, depending on the indicated element type and dimensionality.
template <template <unspecified>
class const_View = const_Vector,
typename T>
class Histogram;Template parameters
const_ViewThe histogram dimensionality: const_Vector for 1D histograms; const_Matrix for 2D histograms.
TThe type of the elements in the views.
Histogram(T min_value, T max_value, length_type num_bin);
Description: Create a Histogram object to collect results constrained by these values:
min_valueThe first element of the result vector accumulates results for all input items that are less than this value.
max_valueThe last element of the result vector accumulates results for all input items that are greater than or equal to this value.
num_binThe number of elements in the result vector.
For each input element V such that
min_value <= V <
max_value, the result element I is
incremented. I is computed as
((V-min_value)/delta)+1, where delta
is (max_value-min_value)/(num_bin-2).
template <unspecified>
const_Vector<scalar_i>
operator()(const_Vector<T, Block> data,
bool accumulate = false)Description: Calls the Histogram on the given input vector. When the parameter
accumulate is true, the results
for this call are added to previous results.
Requirements: This call operator is available only when the template parameter
const_View is const_Vector.
Result: The result vector view is returned as return-value.
template <unspecified>
const_Vector<scalar_i>
operator()(const_Matrix<T, Block> data,
bool accumulate = false)Description: Calls the Histogram on the given input matrix. When the parameter
accumulate is true, the results
for this call are added to previous results.
Requirements: This call operator is available only when the template parameter
const_View is const_Matrix.
Result: The result vector view is returned as return-value.
// Declare a histogram object. Histogram<const_Vector, float> h(0, 8, 10); // Declare the input vector. Vector<float> in(100); ... // Initialize the input vector. // Declare the output vector. Vector<scalar_i> out(10); // Compute the histogram of the input into the output. out = h(in);
This section describes the Infinite Impulse Response filter provided by VSIPL++.
template <typename T = float, object_state Save = state_save, unsigned Number = 0, alg_hint_type Hint = 0> class Iir;
Template parameters
The value-type of the Iir filter
If this object is to be called repeatedly on subsequent chunks of a
long vector, use state_save, else state_nosave
The expected number of times this object will be used. This
is a hint to the library how much effort to spend on upfront optimization.
A value of 0 stands for infinity, and
thus results in the most effort.
One of alg_time, alg_space, or
alg_none. This indicates how the library should
optimize its computation or resource use.
Iir(const_Matrix<T, unspecified> b, const_Matrix<T, unspecified> a, length_type i);
Description: Creates an Iir object...