Author:
- Name: Ilya Kurdyukov
Location: RU - Russian Federation (Russia)
To build:
make all
To use:
./prog < input.jpg > output.jpg
# where the quality of input.jpg is less than 100
Try:
Using your favorite image viewing tool, look at gradient.png
(the original),
quality24.jpg
, and restored.jpg
. The difference is noticeable but subtle.
To see it in detail, observe diff-histeq.png
.
./try.sh
Alternate code:
If you have the jpegint.h
include file from the libjpeg package,
then you will be able to compile the alternate code.
Alternate build:
make alt
NOTE: The above requires the jpegint.h
include file.
Alternate use:
./prog.alt < input.jpg > output.jpg
# where the quality of input.jpg is less than 100
Judges’ remarks:
We were able to guess the meaning of some magic numbers. Can you?
Author’s remarks:
JPEG artifact removal
This program removes compression artifacts from JPEG images using values from quantization tables. After completing its work, the program saves the image in a another JPEG file, but as saved with 100% quality (so output file is larger).
Notes
The lost precision of the DCT coefficient values cannot be gotten out of nowhere. It’s an attempt to find values within possible ranges (defined by the quantization table), which will allow to produce smoother-looking image.
If the image is saved several times with different quantization tables, the artifacts cannot be reduced, since the true range of possible coefficient values isn’t known. If you save with one quality (say 50%) and then with 100%, this code will do nothing.
Don’t expect great results from images saved with extremely low quality (less than 25%). May look blurry.
I written the code with respect of bits per sample set by libjpeg includes, but doesn’t test on something different than common 8 bits.
Alternative versions
prog.alt.c
uses libjpeg internals, which are the inverse of a DCT function that may run faster. Works with many libjpeg distributions.I reduced the code even more, by a hijacking
main()
with file I/O from thejpegtran
utility that comes with libjpeg. You can see this version inprog.nomain.c
. As a useful side effect, you can use command line options comes from this tool, like:./prog -optimize -outfile output.jpg input.jpg
. But for that you must build the program with libjpeg sources.
Extra notes
This is an obfuscated version of JPEG Quant Smooth. The full version is heavily optimized using SIMD/OpenMP and has chroma scaling feature.
Inventory for 2024/kurdyukov2
Primary files
- prog.c - entry source code
- Makefile - entry Makefile
- prog.alt.c - alternate source code
- prog.orig.c - original source code
- diff-histeq.png - quality24.jpg to restored.jpg difference
- gradient.png - original gradient image
- input2.jpg - icon image
- input.jpg - image with quality less than 100
- quality24.png - color gradiant image with quality less than 100
- restored.png - restored quality24.png gradiant image
- try.sh - script to try entry
- prog.nomain.c - source where main comes from jpegtran
Secondary files
- 2024_kurdyukov2.tar.bz2 - download entry tarball
- README.md - markdown source for this web page
- .entry.json - entry summary and manifest in JSON
- .gitignore - list of files that should not be committed under git
- .path - directory path from top level directory
- index.html - this web page