Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMS 161 Introduction to Computing

Similar presentations


Presentation on theme: "COMS 161 Introduction to Computing"— Presentation transcript:

1 COMS 161 Introduction to Computing
Title: HTML Date: March 2, 2005 Lecture Number: 20

2 Announcements Homework Due 3/04/05

3 Review Storing Images RGB Color index Image Compression jpeg

4 Outline Image Compression GIF LZW

5 Compressing Images GIF (Graphic Interchange Format) Codec
Invented by CompuServe as a universal format for graphics GIF compression algorithm owned by Unisys Producers of GIF images need a license GIFs are good for buttons, banners, text (in graphic form), and simplistic images 7

6 Compressing Images Two flavors of GIF images
GIF87a GIF89a Supports animation GIF images allow only 256 colors Allow for a transparent color 7

7 Compressing Images GIF compression algorithm
Why are the sized different? Has to do with the compression algorithm File size: 4814 bytes File size: 5652 bytes 7

8 Compressing Images GIF compression algorithm Horizontal image
Row 1: A big long red line Row 2: A big long red line Row 3: A big long red line Row 4: A big long yellow line Vertical image Row 1: a few green pixels, a few carolina blue pixels, a few red pixels … Row 2: a few green pixels, a few carolina blue pixels, a few red pixels … 7

9 Compressing Images GIF compression algorithm
Vertical image requires more information per row Leads to a larger file Good compression for images with nearly uniform background 7

10 Compressing Images Lempel Ziv Welch compression algorithm
Relies on reoccurrence of byte sequences (strings) A table maps input strings to associated output codes The table initially contains mappings for all possible strings of length one Input is taken one byte at a time to find the longest initial string present in the table The code for that string is output and then the string is extended with one more input byte, b. LZW link 7

11 Compressing Images Lempel Ziv Welch compression algorithm
A new entry is added to the table mapping the extended string to the next unused code (obtained by incrementing a counter) The process repeats, starting from byte b The number of bits in an output code, and hence the maximum number of entries in the table is usually fixed and once this limit is reached, no more entries are added 7

12 LZW Compression Given a stream of text from an alphabet of two letters a and b Rule: Separate the stream of characters into pieces of text so that the shortest piece of data is the string of characters that we have not seen so far aaababbbaaabaaaaaaabaabb aaababbbaaabaaaaaaabaabb 7

13 LZW Compression 0aaababbbaaabaaaaaaabaabb
Insert a 0 at the beginning Assign each section of letters with an increasing number 0aaababbbaaabaaaaaaabaabb 0aaababbbaaabaaaaaaabaabb 1 2 3 4 5 6 7 8 9 10 7

14 LZW Compression Use the indices to number the data
The empty string is labeled 0 a The piece indexed with the 1 is a a with the empty string is labeled 0a aa Is labeled 1a since it contains the string whose index is 1 followed by a new a b In terms of what came before is labeled 0b 7

15 LZW Compression Continue labeling all the pieces in terms of previous labels 0aaababbbaaabaaaaaaabaabb 1 2 3 4 5 6 7 8 9 10 0a1a0b1b3b2a3a6a2b9b 1 2 3 4 5 6 7 8 9 10 7


Download ppt "COMS 161 Introduction to Computing"

Similar presentations


Ads by Google