GithubHelp home page GithubHelp logo

kornelski / jpeg-compressor Goto Github PK

View Code? Open in Web Editor NEW
194.0 27.0 40.0 324 KB

Research JPEG encoder

License: GNU General Public License v3.0

C++ 53.27% C 46.68% Makefile 0.05%
jpeg-encoder jpeg experimental

jpeg-compressor's Introduction

Research JPEG encoder

Codename "Nether Poppleton"


The goal of this encoder is to produce files with best filesize/quality ratio, regardless of encoding speed or memory cost.

Experimental features:

  • Luma-weighed chroma subsampling — thin red lines on white or black background don't become desaturated.
  • Less aggressive DC quantization — less banding (but more blurriness) at very low qualities.
  • Derining by overflowing — less noise around black text on white background.

Usage

Download binary or compile with

make

Run

./encoder source.png output.jpg 50

Examples

These are carefully chosen examples that show certain improvements. They're not indicative of overall performance (and ImageMagick's JPEG encoder is generally okay).

Deringing

JPEG shouldn't be used for line art, but people still do it. Now they can fail less at it.

ImageMagick = 7721B (left), this encoder = 7349B (right)

ImageMagick This encoder

Deringing is implemented by overshooting the white color (technique described here in detail). This way distortions are introduced out of visible range.

Subsampling

Color can be saved at half resolution. Poor subsampling darkens and desaturates red lines.

Original (left), ImageMagick = 7277B (middle), this encoder = 7173B (right)

OriginalImageMagick This encoder

This is done by weighing chroma by luma level. It can be improved further by subsampling with gamma correction and with luma corrections for out-of-range values produced by changes in chroma.

Low DC quantization

Standard JPEG encoders are not tuned for very low quality. Bad quality doesn't have to be that bad.

ImageMagick = 5033B (left), this encoder = 4890B (right)

ImageMagick This encoder

This is done merely by tweaking quantization tables. Further improvements are possible.


Not quite failed experiments

Lossy RLE on DC

I've created algorithm for proper unbiased lossy RLE compression (I can make lossy BMP, lossy PCX and lossy IFF ILBM files!), and wanted to see if it could work when applied to JPEGs DC coefficients. It kinda does a bit, but it often becomes noticeable at 1% file size gain, so overall it may not be worth the effort. Here's a 7% improvement in file size (if you can't see the difference you're sitting too close to the monitor):

Standard Blurred

Grass and rocks at the bottom became flat and bland, but it's hard to see any difference in the trees. Any idea how to detect areas of the image that tolerate this degradation? I've tried looking for noisy areas based on amplitude of selected AC coefficients, but grass and trees have almost the same ACs.

Failed experiments

Blurring DC quantization

JPEG stores average brightness per each 8x8 block, and heavy compression reduces number of brightness levels available (DC quantization), causing obvious blockyness.

I've tried to apply blur that smoothes edges introduced by quantization. Here's an exaggreated example that looks nice:

Standard Blurred

Unfortunately with proper quantization tables there isn't enough fidelity in higher frequencies to make a difference, and bits spent on soft edges could as well be spent on better DC in a first place.

jpeg-compressor's People

Contributors

cooloppo avatar kornelski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.