Git Product home page Git Product logo

sqz's Introduction

SQZ - Low complexity, scalable lossless and lossy image compression library

MIT License

Single-file library for C/C++

For documentation, please refer to the source code

Description

The SQZ codec provides a low-complexity solution for seamless scalability from lossy to fully lossless image compression, allowing for a single compressed image representation to be decoded at the quality level desired by simply truncating the bitstream at any size, with byte-level granularity.

Overview

SQZ is not meant to beat the state-of-the-art extremelly complex image codecs, it was designed with simplicity and practicality in mind. The ideas and methods used were chosen for their suitability to meet the design requirements, and are largely based on previous work.

At its core, SQZ is based on a run-length encoding scheme for discrete wavelet transform tree bitplanes and uses no entropy coding stage.

  • The internal pixel data representation is stored in either 8bpp grayscale mode or in one of 3 possible color spaces, one ensuring perfect reconstruction for lossless compression (YCoCg-R), and the others (Oklab, logl1) vying for better subjective perceptual quality for lossy compression.

  • The 2D DWT subbands are traversed for run-length encoding in one of 4 possible orders based on different space-filling curves, each providing trade-offs in terms of complexity and locality-preservation.

  • The linearized distance between significant subband coefficients at each bitplane is encoded using the Wavelet Difference Reduction (WDR) method.

  • The scheduling of the priorities for encoding the subbands and bitplanes is optimized for producing a sharp image at very large compression rates, so that a downscaled low-quality image preview may be obtained on a very strict allocation budget.

All of these components put together allow SQZ to achieve interesting results, far better than could be expected from such a simple method.

Quality assessment for lossy image compression is always subjective, so you are encouraged to always perform your own evaluation on a dataset representative of your specific needs, but for the sake of completeness, let us examine some results of a comparative objective study against some state-of-the-art image codecs (JPEG 2000 and JPEG-XL) focusing simply on PSNR, on a small dataset consisting mostly of uncompressed photographic images.

SQZ vs JPEG 2000

SQZ vs JPEG 2000

The venerable JPEG 2000 codec is still pretty much the best when it comes to PSNR (consistenly topping even the newer JPEG-XL) and the lack of an entropy coding stage limits SQZ, which trails by about 0.4db at the low end of the PSNR scale and up to about 0.6db at the high end.

However, subjectively, PSNR doesn't always correlate well with perceptual quality (which explains why JPEG-XL is the superior codec of the two), and the Oklab color space provides SQZ with quality benefits that are hard to quantify, especially at high compression ratios.

SQZ vs JPEG-XL

SQZ vs JPEG-XL

Compared to a modern next-gen state-of-the-art codec like JPEG-XL, which also uses a perceptual color space (XYB), provides a better view of what SQZ can offer.

SQZ provides very competitive image quality on a very tight byte budget, and even though it eventually gets outclassed, it does so providing best-in-class scalability at much lower complexity and easy integration. The same SQZ image can be decompressed at each of these quality levels by simply choosing how many bytes to use for decompression, there is no need for reencoding.

Testing methodology

JPEG 2000 and SQZ can compress to an arbitrarily chosen file size, so a direct comparison at each bpp rate was made. For JPEG-XL, each image was encoded with the listed distance parameter, at effort 9, and SQZ decompressed an image matching the size of the resulting .jxl image.

sqz's People

Contributors

marciopais avatar

Stargazers

 avatar Manuel Martinez Torres avatar  avatar Christopher Webb avatar Sean avatar  avatar Jørgen Ibsen avatar  avatar Jonathan Brown avatar Aaron Kaluszka avatar

Watchers

 avatar

Forkers

vrabaud

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.