All Projects → ilyakurdyukov → Jpeg Quantsmooth

ilyakurdyukov / Jpeg Quantsmooth

Licence: lgpl-2.1
JPEG artifacts removal based on quantization coefficients.

Programming Languages

c
50402 projects - #5 most used programming language

Labels

Projects that are alternatives of or similar to Jpeg Quantsmooth

Qreverse
A small study in hardware accelerated AoS reversal
Stars: ✭ 97 (-27.61%)
Mutual labels:  simd
Corrfunc
⚡️⚡️⚡️Blazing fast correlation functions on the CPU.
Stars: ✭ 114 (-14.93%)
Mutual labels:  simd
Jpeg Autorotate
Node module to rotate JPEG images based on EXIF orientation.
Stars: ✭ 127 (-5.22%)
Mutual labels:  jpeg
Photostructure For Servers
PhotoStructure for Servers
Stars: ✭ 98 (-26.87%)
Mutual labels:  jpeg
Imagine
🖼️ PNG/JPEG optimization app for macOS, Windows and Linux.
Stars: ✭ 1,859 (+1287.31%)
Mutual labels:  jpeg
Nnpack
Acceleration package for neural networks on multi-core CPUs
Stars: ✭ 1,538 (+1047.76%)
Mutual labels:  simd
Amplifier.net
Amplifier allows .NET developers to easily run complex applications with intensive mathematical computation on Intel CPU/GPU, NVIDIA, AMD without writing any additional C kernel code. Write your function in .NET and Amplifier will take care of running it on your favorite hardware.
Stars: ✭ 92 (-31.34%)
Mutual labels:  simd
Fastapprox
Approximate and vectorized versions of common mathematical functions
Stars: ✭ 128 (-4.48%)
Mutual labels:  simd
Base64simd
Base64 coding and decoding with SIMD instructions (SSE/AVX2/AVX512F/AVX512BW/AVX512VBMI/ARM Neon)
Stars: ✭ 115 (-14.18%)
Mutual labels:  simd
Blur Detection
Some implementations of algorithms for blur detection in JPEGs
Stars: ✭ 125 (-6.72%)
Mutual labels:  jpeg
Desudesutalk
Steganography for imageboards
Stars: ✭ 100 (-25.37%)
Mutual labels:  jpeg
Packettracer
The SIMD-accelereted ray tracing in C# powered by Intel hardware intrinsic of .NET Core.
Stars: ✭ 109 (-18.66%)
Mutual labels:  simd
Impala
An imperative and functional programming language
Stars: ✭ 118 (-11.94%)
Mutual labels:  simd
Guetzli Gui
A super simple Mac GUI for Google's JPEG encoder, guetzli
Stars: ✭ 97 (-27.61%)
Mutual labels:  jpeg
Bbwebimage
A high performance Swift library for downloading, caching and editing web images asynchronously.
Stars: ✭ 128 (-4.48%)
Mutual labels:  jpeg
Sketch
C++ Implementations of sketch data structures with SIMD Parallelism, including Python bindings
Stars: ✭ 96 (-28.36%)
Mutual labels:  simd
Thorin
The Higher-Order Intermediate Representation
Stars: ✭ 116 (-13.43%)
Mutual labels:  simd
Markdown Themeable Pdf
ARCHIVED. NOT MAINTAINED. Themeable Markdown Converter (Print to PDF, HTML, JPEG or PNG)
Stars: ✭ 130 (-2.99%)
Mutual labels:  jpeg
Docnet
DocNET is as fast PDF editing and reading library for modern .NET applications
Stars: ✭ 128 (-4.48%)
Mutual labels:  jpeg
Lilliput
Resize images and animated GIFs in Go
Stars: ✭ 1,690 (+1161.19%)
Mutual labels:  jpeg

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.

The original project page is here.

WebAssembly

Web version available here. Images are processed locally on your computer. Without multithreading and SIMD optimizations it runs slower than native code.

  • Click the "Load" button or drag-n-drop JPEG image into the browser window. After processing is complete, you can save the result by clicking the "Save" button. You can edit the filename field before saving. The options field is passed to the wasm code when you initiate a processing by loading a file.

Usage

jpegqs [options] input.jpg output.jpg

Options

-q, --quality n Quality setting (0-6, default is 3)
-n, --niter n Number of iterations (default is 3)
-t, --threads n Set the number of CPU threads to use
-o, --optimize Option for libjpeg to produce smaller output file
-v, --verbose n Print libjpeg debug output
-i, --info n Print quantsmooth debug output (default is 15)
Use the sum of flags: 0 - silent, 1/2/4 - various information, 8 - processing time, 16 - SIMD type.
-p, --cpu n Use to lower the SIMD type if CPU detection fails:
0 - auto, 1 - scalar, 2 - SSE2, 3 - AVX2, 4 - AVX512. (x86 build selects between modes 1-3, x86_64 from 2-4)

  • The processing time includes only the smoothing algorithm, jpeg reading and writing time is not included.
  • More iterations can make the result look like CG art, can make the photos look unnatural.

The quality setting sets a combination of flags for processing:

  1. default
  2. adds DIAGONALS flag
    smoother diagonal edges, ~1.5 times slower
  3. adds JOINT_YUV flag
    chroma channels will depend from luminance, better color consistency
  4. adds UPSAMPLE_UV flag
    non-blurring chroma upsampling, unlike fancy upsampling from libjpeg
  • levels 0-2 is the same as 4-6, but with LOW_QUALITY flag
    ~10 times faster, but the quality is lower
    LOW_QUALITY implies DIAGONALS (always set)

Examples

  • Images 3x zoomed.

Original images:

JPEG with quality increasing from 8% to 98%:

After processing:

Buliding on Linux

If your system have libjpeg development package installed, just type make. Tested with libjpeg-turbo8-dev package from Ubuntu-18.04.

Building for Linux distribution

Use the SIMD=select switch, so that jpegqs is compiled for different CPU vector extensions.

amd64 application: make SIMD=select MFLAGS="-m64" clean app
i386 application: make SIMD=select MFLAGS="-m32 -march=i386" clean app

Package dependencies: libc, libjpeg, openmp

Building with libjpeg sources

  1. Download and extract libjpeg sources:
    1. libjpeg, for example version 6b
      wget https://www.ijg.org/files/jpegsrc.v6b.tar.gz
      tar -xzf jpegsrc.v6b.tar.gz
    2. libjpeg-turbo, for example version 2.0.4
      wget -O libjpeg-turbo-2.0.4.tar.gz https://sourceforge.net/projects/libjpeg-turbo/files/2.0.4/libjpeg-turbo-2.0.4.tar.gz
      tar -xzf libjpeg-turbo-2.0.4.tar.gz
  • For a libjpeg (not turbo) you can build jpegqs in a simpler way:
    make JPEGSRC=jpeg-6b
    This uses static configuration from jconfig.h, which should work for common systems.
    The following items are not needed if you do so.
  1. Configure and build libjpeg:

    1. For libjpeg and libjpeg-turbo-1.x.x:
      (cd jpeg-6b && ./configure && make all)
    2. For libjpeg-turbo-2.x.x ./configure script is replaced with cmake:
      (cd libjpeg-turbo-2.0.4 && mkdir -p .libs && (cd .libs && cmake -G"Unix Makefiles" .. && make all))
  2. Tell make where to find libjpeg includes and libjpeg.a
    make JPEGLIB="-Ijpeg-6b jpeg-6b/libjpeg.a
    For a newer versions libjpeg.a is located in a .libs/ dir.

libjpeg build helper

The jpegqs makefile can download sources, extract and compile libjpeg for you. Replace %VER% with a version.

  • libjpeg: make jpeg-%VER%/libjpeg.a Tested versions: 6b, 7, 8d, 9c
  • libjpeg-turbo:make libjpeg-turbo-%VER%/libjpeg.a Tested versions: 1.0.0, 1.4.2, 1.5.3, 2.0.4

It will print you link to archive which you need to download, or you can allow the downloads by adding WGET_CMD=wget to the make command line.

Building on Windows

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

Use as a library

Can be easily added to other software that uses libjpeg to read JPEG images.

  1. Find the source that uses jpeg_start_decompress and jpeg_finish_decompress.
  2. Add include, either quantsmooth.h (compile jpegqs as inline) or libjpegqs.h (link to the jpegqs library).
  3. Change jpeg_ to jpegqs_ for these two functions.
  4. Calling jpegqs_start_decompress takes an additional argument with options, see example.c for how to use it.
  • Build libjpegqs.a static library with make SIMD=select lib

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
 ❓ has an overblurring (-w 0.0 switch makes the result a little sharper, but doesn't fix it)
 ➖ 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].