BTPC Version 5 (Released March 2003)

John Robinson

The Latest: APT

The pages you are now reading document an old version of BTPC. Please see this page for information about APT 1.0, the successor to BTPC.

What is BTPC?

BTPC is a general-purpose image coding scheme suitable for compression of all kinds of image. Its chief strength is that it always performs at least moderately well: there are no image types for which it is substantially worse than a system optimized for that particular type.

For example, here is a thumbnail of a photographic image (original size 768 x 1024):


BTPC can code this picture without loss at 13.7 bits per pixel. By comparison, PNG takes 15.51 bpp and JPEG-LS 14.85 bpp. Here is a graph comparing the lossy coding of the picture by BTPC and two standard alternatives.

PSNR/bpp graph

On the other hand, a graphical image such as this (original size 666 x 458)


is coded losslessly by BTPC at 2.21 bpp, by PNG at 2.25 bpp and by JPEG-LS at 2.67 bpp. Lossy coding is shown here:

PSNR/bpp graph

Results comparing BTPC with competitors on many other images are given at the bottom of this page. In summary:

As a lossy compressor for photographic images, BTPC is, on average, superior to JPEG but inferior to JPEG 2000. It is usually closer to JPEG 2000 than to JPEG. Actual performance depends on image content. Sometimes (as in the water image above) BTPC beats JPEG 2000; sometimes (rarely) it loses to JPEG (e.g. see the results for the Baboon picture below for rates less than 1bpp). For lossy compression of graphics, BTPC is much superior to both JPEG and JPEG 2000. For other imaging modalities (e.g. MRI, SAR) BTPC performs close to JPEG 2000.

When applied losslessly, BTPC has good performance on both natural images and graphics. It is rarely less than 5% worse than the best of JPEG-LS, PNG and GIF and often outperforms all three (as on the above images).

BTPC's lossless coding of bilevel images is usually inferior to CCITT Group IV coding (i.e. READ coding). The worst measured performance for BTPC against standards has been for coding high-resolution document images (e.g. faxes) where it can use twice as many bits as Group IV. However, for detailed bilevel images (e.g. the contours of regions in two-component video coding, or a transparency bitmap) it outperforms Group IV. It far outperforms PNG, JPEG-LS, etc. for bilevel images.

Highly optimized software implementations of JPEG 2000 are now available. Kakuda, for example, is very fast. BTPC averages about the same decode speed as Kakuda for images of equivalent quality. BTPC is much faster than any known version of JPEG-LS.

BTPC uses a binary pyramid, predictive coding and Huffman coding. No part of it is covered by patents. C++ source code is available and may be freely used. BTPC is inherently progressive, and a straightforward modification of the decoder to write directly to an on-screen picture buffer allows simple, progressive, image recovery.

What's new in Version 5?

Version 5 offers better coding of colour and bilevel images than version 4.1. It also adapts better to image size. The cost of these improvements is that BTPC is no longer as fast as the Independent JPEG group's implementation of baseline JPEG. However it is as fast as JPEG 2000 and much faster than competing research systems. The details of the changes will be reported in a journal paper. A preliminary version will be presented at Visual Information Engineering (VIE) 2003, 7-9 July 2003, Guildford, UK.

Where to find it

Source code and makefile for Unix systems are tarred and gzipped here

Source code and executables for Windows are zipped here

These executables are console applications.

A previous version of BTPC is documented in: J A Robinson, "Efficient General-Purpose Image Compression with Binary Tree Predictive Coding", IEEE Transactions on Image Processing, Vol 6, No 4, April 1997, pp 601-607.

and, in more detail, at

When uncompressed and untarred the btpc5.tar.gz file yields sources for two programs:

cbtpc - Convert raw PBM, PGM or PPM file to compressed BTPC

dbtpc - Convert compressed BTPC to PGM or PPM

To make

1. Edit the first line of the makefile if your c++ compiler is not called g++.

2. rename cbtpc.cpp to cbtpc.C etc. if your compiler demands it.

3. make btpc (This will make the cbtpc and dbtpc programs. Also included in the archive are the programs psnr and bpp which I use in testing. If these are useful to you, just do make all.)

To run

cbtpc input_pic output_file [quality]

dbtpc input_file output_pic

The optional quality parameter is a number between 0 and 100. Default is 75. Quality values roughly approximate JPEG quality values, but 100 is lossless.

This version reads PBM, PGM and PPM raw format files (magic number "P4", "P5" or "P6"). It writes PGM and PPM files only.

PC programs

Source code and Windows executables are included in the BTPC zipfile. The executables were made using Microsoft Visual C++. Note that the executables have to run as console applications (e.g. under an MSDOS prompt) because they take command line parameters, just like the Unix versions.

BTPC 5 comparisons with standard algorithms

Comparison methods:

Airplane (Photo)

Baboon (Famous Detailed Photo)

BBC Logo (Graphic)

Screen shot (Graphic)

Old Logo (Graphic)

Diary page (Large bilevel image)

Fruits (Photo)

Frymire (Artwork)

Gears (Graphic)

Graph (Graphic!)

SHDTV Test Image (Mixed)

Lenna (Famous Photo)

Moonlight (Splashscreen)

MRI (Medical)

X-Ray (Medical)

Peppers (Famous Photo)

512x512 Sailboat (Photo)

Same picture, but smaller (Photo)

Same picture, even smaller (Photo)

Same picture, tiny (Photo)

Another sailing picture (Photo)

SAR (Remote sensing)

Serrano (Artwork)

Traceroute (Map graphic)

Tulips (Photo)

Watch (Photorealistic graphic)

Water (Photo)