Note: this is a MATLAB prototype implementation for testing purposes. Check out the C++ implementation instead.
This is a MATLAB implementation (with modifications and improvements) of the thresholding compression method described in the paper Lossy Volume Compression Using Tucker Truncation and Thresholding. For more details on the Tucker transform and tensor-based volume compression, check out my slides.
The core function is thresholding_compression(X,metric,target)
, where:
X
is a volumemetric
is "relative error", "rmse", or "psnr"target
specifies the desired target accuracy (according tometric
)
Try out the code with the example script run.m
:
- Download the bonsai data set (16MB, 8-bit unsigned int) and unpack it as
bonsai.raw
into the project folder. - Compile the C++ file
thresholding/rle_huffman.cpp
into an executablethresholding/rle_huffman
, andthresholding/zigzag.cpp
intothresholding/zigzag
. - In the MATLAB interpreter, go to the project folder and call
run
.
For example, thresholding_compression(X,'rmse',2)
yields about 2.1 RMSE and 1:17 compression rate (left image is a slice from the original, right one from the reconstructed):
You are free to use and modify the code. If you use it for a publication, please cite the paper:
@article{BP:15, year={2015}, issn={0178-2789}, journal={The Visual Computer}, title={Lossy volume compression using {T}ucker truncation and thresholding}, publisher={Springer Berlin Heidelberg}, keywords={Tensor approximation; Data compression; Higher-order decompositions; Tensor rank reduction; Multidimensional data encoding}, author={Ballester-Ripoll, Rafael and Pajarola, Renato}, pages={1-14}}
Our tresholding algorithm exploits the fact that the largest coefficients of the Tucker core tend to concentrate around one spot (the hot corner), that usually encodes the lowest-frequency components. Example:
The algorithm runs these steps sequentially:
- Compute the Tucker decomposition of a volume of size I1 * I2 * I3 into a core of size I1 * I2 * I3 and 3 factor matrices.
- Threshold the core.
- Traverse the result in a 3D zig-zag fashion, starting from the hot corner (where most coefficients survive the thresholding).
- Encode the result as a set of remaining values + a set of I1 * I2 * I3 bits of presence (indicating whether each core value survived the threshold or not).
- Quantize logarithmically the remaining values. Quantize also the Tucker factor matrices.
- Compress the stream of bits-of-presence using run-length encoding, followed by Huffman encoding.
Tensor-based compression is non-local, in the sense that all compressed coefficients contribute to the transformation of each individual voxel (such as Fourier-based transforms, and in contrast to e.g. wavelet transforms or JPEG for images, which uses a localized DCT transform). This can be computationally demanding but decorrelates the data at all spatial scales, thus achieving very competitive compression rates.