12.07.2015 Views

Data Compression: The Complete Reference

Data Compression: The Complete Reference

Data Compression: The Complete Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

28 1. Basic Techniquesby examining its general shape, without any details. If each line is encoded individually,the decoding algorithm can start by decoding and displaying lines 1, 6, 11,..., continuewith lines 2, 7, 12,..., etc. <strong>The</strong> individual rows of the image are interlaced, and theimage is built on the screen gradually, in several steps. This way, it is possible to get anidea of what is in the image at an early stage. Figure 1.8c shows an example of such ascan.(a) (b) (c)Figure 1.8: RLE Scanning.14725836910Another advantage of individual encoding of rows is to make it possible to extractjust part of an encoded image (such as rows k through l). Yet another application is tomerge two compressed images without having to decompress them first.If this idea (encoding each bitmap row individually) is adopted, then the compressedstream must contain information on where each bitmap row starts in the stream. Thiscan be done by writing a header at the start of the stream that contains a group of 4bytes (32 bits) for each bitmap row. <strong>The</strong> kth such group contains the offset (in bytes)from the start of the stream to the start of the information for row k. This increases thesize of the compressed stream but may still offer a good trade-off between space (size ofcompressed stream) and time (time to decide whether to accept or reject the image).<strong>The</strong>re is another, obvious, reason why each bitmap row should be coded individually.RLE of images is based on the idea that adjacent pixels tend to be identical. <strong>The</strong> lastpixel of a row, however, has no reason to be identical to the first pixel of the next row.Figure 1.9a lists Matlab code to compute run lengths for a bi-level image. <strong>The</strong> codeis very simple. It starts by flattening the matrix into a one-dimensional vector, so therun lengths continue from row to row.Disadvantage of image RLE: When the image is modified, the run lengths normallyhave to be completely redone. <strong>The</strong> RLE output can sometimes be bigger than pixelby-pixelstorage (i.e., an uncompressed image, a raw dump of the bitmap) for complexpictures. Imagine a picture with many vertical lines. When it is scanned horizontally,it produces very short runs, resulting in very bad compression, or even in expansion.A good, practical RLE image compressor should be able to scan the bitmap by rows,

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!