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.

26 1. Basic Techniquesrow by row, looking for runs of pixels of the same color. If the bitmap starts, e.g., with17 white pixels, followed by 1 black one, followed by 55 white ones, etc., then only thenumbers 17, 1, 55,...need be written on the output stream.<strong>The</strong> compressor assumes that the bitmap starts with white pixels. If this is nottrue, then the bitmap starts with zero white pixels, and the output stream should startwith 0. <strong>The</strong> resolution of the bitmap should also be saved at the start of the outputstream.<strong>The</strong> size of the compressed stream depends on the complexity of the image. <strong>The</strong>more detail, the worse the compression. However, Figure 1.7 shows how scan lines gothrough a uniform area. A line enters through one point on the perimeter of the areaand exits through another point, and these two points are not “used” by any other scanlines. It is now clear that the number of scan lines traversing a uniform area is roughlyequal to half the length (measured in pixels) of its perimeter. Since the area is uniform,each scan line contributes one number to the output stream. <strong>The</strong> compression ratio ofa uniform area thus roughly equals the ratiohalf the length of the perimetertotal number of pixels in the area .Figure 1.7: Uniform Areas and Scan Lines.⋄ Exercise 1.1: What would be the compressed file in the case of the following 6 × 8bitmap?RLE can also be used to compress grayscale images. Each run of pixels of thesame intensity (gray level) is encoded as a pair (run length, pixel value). <strong>The</strong> run lengthusually occupies one byte, allowing for runs of up to 255 pixels. <strong>The</strong> pixel value occupiesseveral bits, depending on the number of gray levels (typically between 4 and 8 bits).Example: An 8-bit deep grayscale bitmap that starts with12, 12, 12, 12, 12, 12, 12, 12, 12, 35, 76, 112, 67, 87, 87, 87, 5, 5, 5, 5, 5, 5, 1,...

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

Saved successfully!

Ooh no, something went wrong!