SOPT
Sparse OPTimisation
Functions
wavelets.cc File Reference
#include "sopt/wavelets/wavelets.h"
+ Include dependency graph for wavelets.cc:

Go to the source code of this file.

Functions

int main (int, char const **)
 

Function Documentation

◆ main()

int main ( int  ,
char const **   
)

Definition at line 3 of file wavelets.cc.

3  {
4  // Creates Daubechies 4 wavelet, with 5 levels
5  auto const wavelets = sopt::wavelets::factory("DB4", 5);
6 
7  // Creates a random signal
9  // Now gets its coefficients
10  auto coefficients = wavelets.direct(input);
11  // And transform back
12  auto recover = wavelets.indirect(coefficients);
13  // Check the reconstruction is corrrect
14  if (not input.isApprox(recover)) throw std::exception();
15 
16  // To save on memory allocation we could also use a pre-allocated matrix;
17  coefficients.fill(0);
18  recover.fill(0);
19  wavelets.direct(coefficients, input);
20  wavelets.indirect(coefficients, recover);
21  if (not input.isApprox(recover)) throw std::exception();
22 
23  // Finally, it is possible to use expressions
24  // For instance, we can do a 1d transform on a single row
25  wavelets.direct(coefficients.row(2).transpose(), input.row(2).transpose() * 2);
26  wavelets.indirect(coefficients.row(2).transpose(), recover.row(2).transpose());
27  if (not input.row(2).isApprox(recover.row(2) * 0.5)) throw std::exception();
28 
29  return 0;
30 }
Wavelet factory(const std::string &name, t_uint nlevels)
Creates a wavelet transform object.
Definition: wavelets.cc:8
Eigen::Array< T, Eigen::Dynamic, Eigen::Dynamic > Image
A 2-dimensional list of elements of given type.
Definition: types.h:39

References sopt::wavelets::factory().