vspline 1.1.0
Generic C++11 Code for Uniform B-Splines
Classes | Functions
bls.cpp File Reference

fidelity test More...

#include <random>
#include <vigra/accumulator.hxx>
#include <vigra/multi_math.hxx>
#include <vspline/vspline.h>
#include <vigra/multi_fft.hxx>

Go to the source code of this file.

Classes

struct  offset_f
 invoke with: bls <spline degree> <number of iterations> \ [ <frequency cutoff> ] More...
 

Functions

int main (int argc, char *argv[])
 

Detailed Description

fidelity test

This is a test to see how much a signal degrades when it is submitted to a sequence of operations:

Finally, a last shift is performed which samples the penultimate version of the signal at points coinciding with coordinates 0...N-1 of the original signal. This last iteration should ideally recreate the original sequence, and you'll see a cumulated offset of zero for this last iteration.

The test is done with a periodic signal to avoid margin effects. The initial sequence is created by performing an IFFT on random data up to a given cutoff frequency, producing a band-limited signal. Alternatively, by modifying the initial values which are put into the frequency-domain representation of the test signal, more specific scenarios can be investigated (try setting the values to 1 uniformly etc) With the cutoff factor approaching 1.0, the signal contains more and higher high frequencies, making it ever more difficult for the spline to represent the data faithfully. With a cutoff of <= .5, fidelity is very high for high-degree b-splines; even after many iterations the spline is nearly unchanged and faithfully represents the original signal.

There are two factors to observe: high-degree splines cope better with high frequency components, but they suffer from the large magnitude of coefficient values, making the evaluation error larger - especially since high-degree splines have wide support.

An important conclusion is that even though all input signals produced with this test are band-limited by design, this quality is not sufficient to produce a b-spline from them which is 'stable' in the sense of being immune to the multiple shifting operation, unless the signal is free from frequencies above half the Nyquist frequency.

If the input contains high frequencies, and yet a faithful b-spline representation has to be provided which is immune to shifting, one solution is to create a high-degree spline over the signal, sample it at half unit steps and use the resulting signal to create the 'working' spline. By creating the high-order 'super-spline', a signal is created which is low in high-frequency content and can be faithfully represented by the working spline. The upsampling can also be done in any other way, like FFT/IFFT. See n_shift.cc for an implementation of upsampling using a high-degree b-spline as 'super-spline'.

An aside: this program shows that we can easily shift and resample a high-degree periodic spline for thousands of times without much signal degradation, which is quite remarkable, but requires the signal to be band-limited to half the Nyquist frequency. But if we look at the fourier transformation of each of the shifted variants of the signal, we don't - as we might expect - get precisely the same magnitudes for the partial frequencies. I'm not quite sure what to make of this.

note that this example requires fftw3.

compile with: clang++ -O3 -std=c++11 -obls bls.cpp \ -pthread -lvigraimpex -lfftw3

to use highway, add -DUSE_HWY and -lhwy to use Vc, add -DUSE_VC and -lVc to use std::simd, use -DUSE_STDSIMD and –std=c++17

Definition in file bls.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 136 of file bls.cpp.