Skip to main content

A universal C++ compression library based on wavelet transformation

Project description

example workflow codecov

WaveletBuffer

A universal C++ compression library based on wavelet transformation

Features

  • Written in Modern C++
  • One-side wavelet decomposition for vectors and matrices
  • 5 Daubechies Wavelets DB1-DB5
  • Different denoising algorithms
  • Fast and efficient compression with MatrixCompressor
  • Cross-platform

Requirements

  • CMake >= 3.16
  • C++20 compiler
  • conan >= 1.56, < 2.0

Bindings

Usage Example

#include <wavelet_buffer/wavelet_buffer.h>

using drift::Signal1D;
using drift::WaveletBuffer;
using drift::WaveletParameters;
using drift::WaveletTypes;
using DenoiseAlgo = drift::ThresholdAbsDenoiseAlgorithm<float>;

int main() {
  Signal1D original = blaze::generate(
      1000, [](auto index) { return static_cast<float>(index % 100); });

  std::cout << "Original size: " << original.size() * 4 << std::endl;
  WaveletBuffer buffer(WaveletParameters{
      .signal_shape = {original.size()},
      .signal_number = 1,
      .decomposition_steps = 3,
      .wavelet_type = WaveletTypes::kDB1,
  });

  // Wavelet decomposition of the signal and denoising
  buffer.Decompose(original, DenoiseAlgo(0, 0.3));

  // Compress the buffer
  std::string arch;
  buffer.Serialize(&arch, 16);
  std::cout << "Compressed size: " << arch.size() << std::endl;

  // Decompress the buffer
  auto restored_buffer = WaveletBuffer::Parse(arch);
  Signal1D output_signal;

  // Restore the signal from wavelet decomposition
  restored_buffer->Compose(&output_signal);

  std::cout << "Distance between original and restored signal: "
            << blaze::norm(original - output_signal) / original.size()
            << std::endl;
  std::cout << "Compression rate: " << original.size() * 4. / arch.size() * 100
            << "%" << std::endl;
}

Build and Installing

On Ubuntu:

git clone https://github.com/panda-official/WaveletBuffer.git

mkdir build && cd build
cmake -DWB_BUILD_TESTS=ON -DWB_BUILD_BENCHMARKS=ON -DWB_BUILD_EXAMPLES=ON -DCODE_COVERAGE=ON ..
cmake --build . --target install

On MacOS:

git clone https://github.com/panda-official/WaveletBuffer.git
mkdir build && cd build
cmake -DWB_BUILD_TESTS=ON -DWB_BUILD_BENCHMARKS=ON -DWB_BUILD_EXAMPLES=ON -DCODE_COVERAGE=ON ..
cmake --build . --target install

On Windows:

git clone https://github.com/panda-official/WaveletBuffer.git
mkdir build && cd build
cmake -DWB_BUILD_TESTS=ON -DWB_BUILD_BENCHMARKS=ON -DWB_BUILD_EXAMPLES=ON -DCODE_COVERAGE=ON ..
cmake --build . --config Release --target install

Integration

Using cmake target

find_package(wavelet_buffer REQUIRED)

add_executable(program program.cpp)
target_link_libraries(program wavelet_buffer::wavelet_buffer)

# WaveletBuffer use blaze as linear algebra library which expects you to have a LAPACK library installed
# (it will still work without LAPACK and will not be reduced in functionality, but performance may be limited)
find_package(LAPACK REQUIRED)
target_link_libraries(program ${LAPACK_LIBRARIES})

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wavelet-buffer-0.7.1.tar.gz (60.2 kB view hashes)

Uploaded Source

Built Distributions

wavelet_buffer-0.7.1-cp311-cp311-win_amd64.whl (1.4 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

wavelet_buffer-0.7.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (831.8 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

wavelet_buffer-0.7.1-cp311-cp311-macosx_10_9_x86_64.whl (748.5 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

wavelet_buffer-0.7.1-cp310-cp310-win_amd64.whl (1.4 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

wavelet_buffer-0.7.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (831.8 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

wavelet_buffer-0.7.1-cp310-cp310-macosx_10_9_x86_64.whl (748.5 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

wavelet_buffer-0.7.1-cp39-cp39-win_amd64.whl (1.4 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

wavelet_buffer-0.7.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (832.1 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

wavelet_buffer-0.7.1-cp39-cp39-macosx_10_9_x86_64.whl (748.6 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

wavelet_buffer-0.7.1-cp38-cp38-win_amd64.whl (1.4 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

wavelet_buffer-0.7.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (831.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

wavelet_buffer-0.7.1-cp38-cp38-macosx_10_9_x86_64.whl (748.5 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page