ImageProcessing-ElectronicPublications / libjpegqs

Library JPEG Quant Smooth
https://github.com/ilyakurdyukov/jpeg-quantsmooth
GNU Lesser General Public License v2.1
10 stars 3 forks source link
dct image jpeg library simd unjpeg

GitHub release (latest by date) GitHub Release Date GitHub repo size GitHub all releases GitHub

Library JPEG Quant Smooth

This program tries to recreate lost precision of DCT coefficients based on quantization table from jpeg image. Output saved as jpeg image with quantization set to 1 (like jpeg saved with 100% quality). You can save smoothed image with original quantization tables resulting in same DCT coefficients as in original image.

You may not notice jpeg artifacts on the screen without zooming in, but you may notice them after printing. Also, when editing compressed images, artifacts can accumulate, but if you use this program before editing - the result will be better.

WebAssembly

Web version available here. Runs in your browser, none of your data is send outside. But without multithreading and SIMD optimizations it works noticeably slower.

Usage

jpegqs [options] input.jpg output.jpg

Options

--optimize Smaller output file.

--verbose n Print debug info form libjpeg.

--info n Print debug info from quantsmooth (on by default, set to 0 to disable).

--border N.N Size border (default = 2.0)

--gain N.N Gain coefficients (default = 2.0)

--scale N.N Scale delta coefficients (default = 1.0)

--niter N Number iteration (default = 3)

Examples

Note: Images 3x zoomed.

Original images:

JPEG with quality increasing from 8% to 98%:

After processing:

Buliding on Linux

If you have "libjpeg-dev" package installed, just type:

make

Tested with packages from Ubuntu-18.04, and from sources: libjpeg (6b), libjpeg-turbo (1.4.2, 1.5.3, 2.0.4).

If you do not want to use SSE, type:

make CFLAGS="-fopenmp -O2 -mno-sse2"

If you do not want to use OPENMP (MacOS), type:

make MPFLAGS=

Or when using libomp (MacOS):

make MPFLAGS="-Xpreprocessor -fopenmp -lomp"

With libjpeg 6b form sources

wget https://www.ijg.org/files/jpegsrc.v6b.tar.gz
tar -xvzf jpegsrc.v6b.tar.gz
(cd jpeg-6b && ./configure && make all)
make LIBS="-I jpeg-6b jpeg-6b/libjpeg.a -lm"

Building on Windows

Get MSYS2, install needed packages with pacman and build with release.sh. If you not familiar with building unix applications on windows, then you can download program from releases.

Alternatives and comparison

Similar projects, and how I see them after some testing.

jpeg2png:
 ✔️ good documentation and math model
 ✔️ has tuning options
 ✔️ better at deblocking low quality JPEG images
 ❓ little blurry in default mode (compared to quantsmooth), but can be tuned
 ➖ 10 to 20 times slower
 ➖ less permissive license (GPL-3.0)

jpeg2png can provide roughly same quality (better in not common cases), but significantly slower.

knusperli:
 ✔️ more permissive license (Apache-2.0)
 ➖ you can hardly see any improvements on the image
 ➖ no performance optimizations (but roughly same speed as for quantsmooth with optimizations)
 ➖ no any command line options
 ➖ uncommon build system

knusperli is good for nothing, in my opinion.

Base project page

https://github.com/ilyakurdyukov/jpeg-quantsmooth

Project page

https://github.com/ImageProcessing-ElectronicPublications/libjpegqs

2020