A deblocking JPEG decoder

Overview

Knusperli

The goal of Knusperli is to reduce blocking artifacts in decoded JPEG images, by interpreting quantized DCT coefficients in the image data as an interval, rather than a fixed value, and choosing the value from that interval that minimizes discontinuities at block boundaries.

a traditional JPEG decoder (Imagemagick 7.0.8-59) Knusperli
baboon JPEG, zoomed baboon Knusperli, zoomed
baboon JPEG baboon Knusperli

Building

Knusperli builds with Bazel:

CC=gcc bazel build :knusperli
bazel-bin/knusperli input.jpg output.png

Details

A JPEG encoder quantizes DCT coefficients by rounding coefficients to the nearest multiple of the elements of the quantization matrix. For every coefficient, there is an interval of values that would round to the same multiple. A traditional decoder uses the center of this interval to reconstruct the image. Knusperli instead chooses the value in the interval that reduces discontinuities at block boundaries. The coefficients that Knusperli uses, would have rounded to the same values that are stored in the JPEG image.

Disclaimer

This is not an officially supported Google product.

Comments
  • Replace the picture of Lena

    Replace the picture of Lena

    Fixes #4 Some people find the picture of Lena offensive, so this commit replaces it by another well-known picture in the image compression community: mandrill.jpg

    See: http://sipi.usc.edu/database/database.php?volume=misc&image=10#top

    new README.md, rendered

    opened by lovasoa 5
  • bazel build fails during evaluating WORKSPACE file

    bazel build fails during evaluating WORKSPACE file

    # bazel version
    Build label: 0.23.0
    Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
    Build time: Tue Feb 26 17:42:16 2019 (1551202936)
    Build timestamp: 1551202936
    Build timestamp as int: 1551202936
    

    here the actual error-message:

    # CC=gcc bazel build :knusperli
    ERROR: /home/bastian/software/knusperli/WORKSPACE:1:1: name 'new_git_repository' is not defined
    ERROR: Error evaluating WORKSPACE file
    ERROR: error loading package '': Encountered error while reading extension file 'tools/build_defs/repo/http.bzl': no such package '@bazel_tools//tools/build_defs/repo': error loading package 'external': Could not load //external package
    ERROR: error loading package '': Encountered error while reading extension file 'tools/build_defs/repo/http.bzl': no such package '@bazel_tools//tools/build_defs/repo': error loading package 'external': Could not load //external package
    INFO: Elapsed time: 0.142s
    INFO: 0 processes.
    FAILED: Build did NOT complete successfully (0 packages loaded)
    

    I did not changed anything, this is a fresh checkout and the WORKSPACE file has newer changed according to git history. What I'am doing wrong?

    opened by bittorf 2
  • Use an alternative to Lenna for image samples

    Use an alternative to Lenna for image samples

    The Lenna/Lena image is from a Playboy centrefold. The image compression community has been moving away from its use since the 1990's.

    There are plenty of alternative images that you can use to demonstrate deblocking, including some that have been around nearly as long as Lenna, such as Mandrill or Peppers, available here: http://sipi.usc.edu/database/database.php?volume=misc&image=13#top

    Note also that SIPI has removed access to Lenna as well as other images of dubious origin.

    opened by cocoademon 1
  • Fix

    Fix "warning: control reaches end of non-void function" in decode.cc

    I discovered that there's no explicit return statement at the end of int main() function while moving from C++ to Rust in my fork. Bazel doesn't report this warning at all, even with -Wall.

    opened by ziemek99 0
  • Fix .gitignore

    Fix .gitignore

    .gitignore doesn't work at all because of trailing slashes, which is wrong because Bazel "directories" are actually symlinks and should be treated as files. This PR simplifies the rule, too.

    opened by ziemek99 0
  • Added fuzzers to be run with OSS-Fuzz.

    Added fuzzers to be run with OSS-Fuzz.

    Hi maintainers,

    It would be nice to have this project fuzzed by way of OSS-Fuzz, which is a service run by Google that performs continuous fuzzing of open source projects.

    Over here: https://github.com/google/oss-fuzz/pull/5016 I have set up the necessary artifacts to get the project integrated. In that PR you also see the fuzzer attached, but it would be nicer to have the fuzzer integrated into the upstream project itself rather than keeping it in OSS-Fuzz - so if this PR gets merged I will remove it from OSS-Fuzz. For integration, the only thing we need email of the maintainers that will be receiving access to bug reports, coverage reports and similar.

    If you have any questions you can ask me, but as this is a Google open source project I assume you can reach out internally to @inferno-chromium

    opened by DavidKorczynski 0
  • Unexpected end of input

    Unexpected end of input

    I wanted to test this so I saved a new JPEG image in MS Paint (this), but I am getting an error when I try to convert this image:

    Unexpected end of input: pos=230 need=162 len=273
    Error reading jpeg data from input file.
    

    This image is in yuv420p. When I convert the image with ffmpeg to a new JPEG file, it works on it.

    opened by IllidanS4 1
  • Deleting on-topic comments without consent in issue #4

    Deleting on-topic comments without consent in issue #4

    @jyrkialakuijala After saying "Thank you everyone for sharing your views on this topic.", you deleted all on-topic comments that you could. One-sidedly. And I gotta tell you that is a pretty nasty thing to do. You have no right to silence people on an open platform like this one for contributing to a valid discussion.

    Link to issue #4 for reference.

    opened by tagcup 0
Owner
Google
Google ❤️ Open Source
Google
An 'embedded-friendly' (aka Arduino) JPEG image encoding library

Starting in the late 80's I wrote my own imaging codecs for the existing standards (CCITT G3/G4 was the first). I soon added GIF, JPEG and not long after that, the PNG specification was ratified. All of this code was "clean room" - written just from the specification. I used my imaging library in many projects and products over the years and recently decided that some of my codecs could get a new lease on life as open source, embedded-friendly libraries for microcontrollers.

Larry Bank 36 Oct 16, 2022
Guetzli is a JPEG encoder that aims for excellent compression density at high visual quality

Guetzli is a JPEG encoder that aims for excellent compression density at high visual quality. Guetzli-generated images are typically 20-30% smaller than images of equivalent quality generated by libjpeg. Guetzli generates only sequential (nonprogressive) JPEGs due to faster decompression speeds they offer.

Google 12.8k Dec 1, 2022
Python envelope for the popular C library libjpeg for handling JPEG files.

jpeglib Python envelope for the popular C library libjpeg for handling JPEG files. libjpeg offers full control over compression and decompression and

Martin Benes 6 Nov 13, 2022
Arduino PNG image decoder library

An 'embedded-friendly' (aka Arduino) PNG image decoding library

Larry Bank 99 Nov 26, 2022
Simple, generally spec-compliant, hacky PNG Decoder written in C99.

Simple, generally spec-compliant, hacky PNG Decoder written in C99.

cristei 2 Nov 2, 2021
PNG encoder and decoder in C and C++.

PNG encoder and decoder in C and C++, without dependencies

Lode Vandevenne 1.7k Nov 23, 2022
Tiny ISO-compliant C++ EXIF and XMP parsing library for JPEG.

TinyEXIF: Tiny ISO-compliant C++ EXIF and XMP parsing library for JPEG Introduction TinyEXIF is a tiny, lightweight C++ library for parsing the metada

cDc 83 Nov 17, 2022
Single header lib for JPEG encoding. Public domain. C99. stb style.

tiny_jpeg.h A header-only public domain implementation of Baseline JPEG compression. Features: stb-style header only library. Does not do dynamic allo

Sergio Gonzalez 209 Nov 22, 2022
JPEG XL image format reference C++ implementation

This repository contains a reference implementation of JPEG XL (encoder and decoder), called libjxl.

libjxl 853 Nov 25, 2022
An 'embedded-friendly' (aka Arduino) JPEG image encoding library

Starting in the late 80's I wrote my own imaging codecs for the existing standards (CCITT G3/G4 was the first). I soon added GIF, JPEG and not long after that, the PNG specification was ratified. All of this code was "clean room" - written just from the specification. I used my imaging library in many projects and products over the years and recently decided that some of my codecs could get a new lease on life as open source, embedded-friendly libraries for microcontrollers.

Larry Bank 36 Oct 16, 2022
Guetzli is a JPEG encoder that aims for excellent compression density at high visual quality

Guetzli is a JPEG encoder that aims for excellent compression density at high visual quality. Guetzli-generated images are typically 20-30% smaller than images of equivalent quality generated by libjpeg. Guetzli generates only sequential (nonprogressive) JPEGs due to faster decompression speeds they offer.

Google 12.8k Dec 1, 2022
Python envelope for the popular C library libjpeg for handling JPEG files.

jpeglib Python envelope for the popular C library libjpeg for handling JPEG files. libjpeg offers full control over compression and decompression and

Martin Benes 6 Nov 13, 2022
Analysing and implementation of lossless data compression techniques like Huffman encoding and LZW was conducted along with JPEG lossy compression technique based on discrete cosine transform (DCT) for Image compression.

PROJECT FILE COMPRESSION ALGORITHMS - Huffman compression LZW compression DCT Aim of the project - Implement above mentioned compression algorithms an

null 1 Dec 14, 2021
JS/WASM build of libjxl (JPEG-XL)

libjxl-js JS/WASM build of libjxl (JPEG-XL) Try It Out! Try it in your browser here Building This project uses git submodules to pull in libjxl. If de

Chris Hafey 11 Nov 12, 2022
Second life for famous JPEGView - fast and tiny viewer/editor for JPEG, BMP, PNG, WEBP, TGA, GIF and TIFF images with a minimalist GUI and base image processing.

JPEGView-Image-Viewer-and-Editor Updated Dec 07 2021. Version 1.1.1.0 has been released. Download link1, link2 added. Second life for famous JPEGView

Ann Hatt 36 Nov 23, 2022
Single header lib for JPEG encoding. Public domain. C99. stb style.

tiny_jpeg.h A header-only public domain implementation of Baseline JPEG compression. Features: stb-style header only library. Does not do dynamic allo

Sergio Gonzalez 209 Nov 22, 2022
MozJPEG improves JPEG compression efficiency achieving higher visual quality and smaller file sizes at the same time

Mozilla JPEG Encoder Project MozJPEG improves JPEG compression efficiency achieving higher visual quality and smaller file sizes at the same time. It

Mozilla 5k Nov 22, 2022
Minimalistic MP3 decoder single header library

minimp3 Minimalistic, single-header library for decoding MP3. minimp3 is designed to be small, fast (with SSE and NEON support), and accurate (ISO con

Lion 1.2k Nov 24, 2022
Minimal Huffman coder/decoder

huffandpuff This is an extremely minimal huffman encoder/decoder. It uses no calls at all, not even stdlib/stdio, making it suitable for embedded appl

Adam Ierymenko 89 Nov 28, 2022
Minimalistic MP3 decoder single header library

minimp3 Minimalistic, single-header library for decoding MP3. minimp3 is designed to be small, fast (with SSE and NEON support), and accurate (ISO con

Lion 1.2k Nov 24, 2022