UnBlock: Remove the “blockies” from images and videos

What is UnBlock?

UnBlock is an algorithm I invented in late 2005 that seeks to remove the “blockiness” of heavily or moderately compressed JPEG images, without degrading the sharpness of the original image, and without the need for any “tuning” or “tweaking”: the algorithm learns about the block edges from the image itself. The algorithm is described in detaiil in the following research paper:

A reference ANSI C implementation of UnBlock is provided at the bottom of this page.

UnBlock has also been used by other researchers on video formats that use a similar block encoding to JPEG. Those results are not contained on this page.

At the time I released UnBlock (early 2006), the best existing automatic deblocking filter commercially available was from Pegasus Imaging. Click here to see a “head-to-head” between Pegasus and UnBlock, that I created at the time. (The President of Pegasus Imaging publicly stated at that time that UnBlock also out-performed Pegasus’s own new patented but unreleased deblocking algorithm.)

Sample results

The following sample results have been on this page since 2006, but the actual images now shown below have been generated using the ANSI C code below.

The original JPEG-compressed file, at the corresponding JPEG quality setting (using the standard IJG JPEG library), is on the left; the UnBlocked image obtained from running that JPEG image through UnBlock is on the right. The compression ratios are relative to the uncompressed (e.g. BMP) image file size. For the higher-quality originals, discerning the block artifacts may be easier if you download the actual image files, as zooming on your browser may mask some of those artifacts.

  JPEG quality 0   (104:1 compression)

  JPEG quality 5   (83:1 compression)

  JPEG quality 10   (60:1 compression)

  JPEG quality 20   (41:1 compression)

  JPEG quality 60   (22:1 compression)

  JPEG quality 80   (14:1 compression)

  JPEG quality 90   (10:1 compression)

  JPEG quality 95   (6.8:1 compression)

  JPEG quality 100   (3.2:1 compression)

Original image

Reference ANSI C implementation of UnBlock

The reference implementation of UnBlock is contained in the following ANSI C code:

There is one sample program included:

Run a JPEG image through the UnBlock algorithm, and write the result out to a PNG or JPEG file.

There are also 54 executables of unit tests and death tests provided.

Instructions for building the code are contained in the _README file within the archive.

Note that all code provided here is from my personal codebase, and is supplied under the MIT License.

Other image processing resources

If you like UnBlock, then you may also find useful the following image processing resources that I have put into the public domain over the decades:

The Magic Kernel
World-beating resizing algorithm, superior to the popular Lanczos kernels, that helps power Facebook and Instagram (2006–2021).
The Magic Edge Detector
Edge detection algorithm, leveraging the power of the Magic Kernel, that is superior to the common Sobel, Scharr, Prewitt, and Roberts-cross algorithms (2011–2021).
A top-down progressive image (mipmapping) algorithm, leveraging the power of the Magic Kernel (2006–2021).
3D JPEG-Clear
The same algorithm as JPEG-Clear, but applied to 3D volumetric data (2010–2021).
Position-space deblurring algorithm (1999–2021).


This page describes personal hobby research that I have undertaken since 2005. All opinions expressed herein are mine alone. I put UnBlock into the public domain, via this page and its predecessor on my previous domain, in early 2006. All code provided here is from my personal codebase, and is supplied under the MIT License.