A universal C++ compression library based on wavelet transformation
Project description
WaveletBuffer
A universal C++ compression library based on wavelet transformation
Requirements
- CMake >= 3.16
- C++17 compiler
- conan
Bindings
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
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})
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;
}
Project details
Release history Release notifications | RSS feed
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.1.1.tar.gz
(37.8 kB
view hashes)
Built Distributions
Close
Hashes for wavelet_buffer-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2457602e898bb9c52fc79819eb187ec6777e5b446a2e4366a8eacab14e11ce58 |
|
MD5 | 27e01099b25ff77aa6c6f47b84b52289 |
|
BLAKE2b-256 | 68d71d6fcecb5fb0ccec41e491e19903b542315bc51eab8f2a0c5188e4004dc1 |
Close
Hashes for wavelet_buffer-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 684013685065ab5b8ae674930cc2ed17978ca4f60996aee32c1559d5380843df |
|
MD5 | 656b09fa5b467e9629da7dca646da7ae |
|
BLAKE2b-256 | 6b987582c885494c4707cc3cd7846793646ddaf1a4bad85d58ab2997f3176564 |
Close
Hashes for wavelet_buffer-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ad07ab0adc2d8e97b90eb4d6b7e523664742dd496f12b5228f52f3d3eb2c6e8 |
|
MD5 | 1c7f4c858e347e194ab5a070c27c72e1 |
|
BLAKE2b-256 | 64571af0f8171bfd7c3a07846b7b4163705af26131a2002b02750008bf3bd131 |