images 01/29/04 resources: yale web style guide the gif controversy unisys - lzw

22
Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

Upload: octavia-green

Post on 02-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

Images

01/29/04Resources:Yale Web Style GuideThe GIF ControversyUnisys - lzw

Page 2: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

Image CharacteristicsImage Characteristics

SizeImage Size: Dimension in pixelsCanvas Size: Dimension in inches

Screen Resolution (Pixels per inch)72 –96 ppi for a monitor300-1200 ppi for print

Page 3: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

Image CharacteristicsImage Characteristics

Color True Color

8 bits per Red, Green, BlueOr 24 bits per pixel

Given a square image with a dimension of 4 inches and given 2 ppi. What file size would be needed just to store the image data (in bits)?

Page 4: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

Image CharacteristicsImage Characteristics

Color True Color

8 bits per Red, Green, BlueOr 24 bits per pixel

Given a square image with a dimension of 4 inches and given 72 ppi. What file size would be needed just to store the image data (in bits)?

24bits/pixel * 72 pixels/inch * 4 inches/scan line = 6912 bits/scan line6912 bits/scan line * 72 scan lines/inch * 4 inches = ~ 2000 K

Page 5: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

Image CharacteristicsImage Characteristics

Given a square image with a dimension of 4 inches and given 300 ppi. What file size would be needed just to store the raw image data (in bits)?

Page 6: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

Image CharacteristicsImage Characteristics

Given a square image with a dimension of 4 inches and given 300 ppi. What file size would be needed just to store the raw image data (in bits)?

24bits/pixel * 300 pixels/inch * 4 inches/scan line = 28800bits/scan line

28800bits/scan line * 300 scan lines/inch * 4 inches = 34560 K

Page 7: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

Image TransmissionImage Transmission

Most Internet users connect at 56K modems. The download rate for a 56K modem is actually pretty close to 7K.

To transmit ~ 34560 K would take ~one hourTo transmit ~2000K will take ~4.76 minutes

Studies show that users get impatient after a 2 second delay.

Implications?

Page 8: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

Compression : What is it?Compression : What is it?

The goal of data compression is to represent an information source (e.g. a data file, a speech signal, an image, or a video signal) as accurately as possible using the fewest number of bits.

Page 9: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

Image Compression : Web Formats

Image Compression : Web Formats

GIF – lossy for more than 256 colorsFor line drawings, gray scale images and color

pictures with a palette of 256 colors or fewerJPG – always lossy

For true color images, especially photographsPNG - lossless

Not well supported in IEReplacement format for GIF

Page 10: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

Compression : How does it work?

Compression : How does it work?

Describe the algorithm.A procedure or formula for solving a problem. An algorithm can be described in

Pseudocode> An outline of an algorithm, written in a form that can easily be

converted into a program.> There are no formatting or syntax rules> Enables the programmer to concentrate on the algorithms

without worrying about all the syntactic details of a particular programming language

Page 11: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

Run Length EncodingRun Length Encoding

RLE is used in TIFF and PDF filesFor a binary image, given the dimensions of the

image (r x c) and that (x0, x1, . . . , x((r*c)-1) are image pixels with one of two possible intensity values (0 or 1), the image line can be said to consist of k image segments having length li.

Assume that the initial image segment has a white value or value of 1.

Page 12: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

Run Length EncodingPseudo Code

Run Length EncodingPseudo Code

 

initialize RunColor to 1 initialize RunLength to 0 for each pixel in the image if (pixel is the same as the RunColor) increment RunLength else write RunLength change RunColor to pixel's intensity initialize RunLength to 1write last RunLength 

Page 13: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

 

initialize RunColor to 1

initialize RunLength to 0

for each pixel in the image

if (pixel is the same as the RunColor)

increment RunLength

else

write RunLength

change RunColor to pixel's intensity

initialize RunLength to 1

write last RunLength 

Page 14: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

Three Programming Contructs

Three Programming Contructs

1. Sequence construct Statements are executed in the order they're found

in the code.

X = 3Y = 2Z = X * Y

Page 15: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

Three Programming Contructs

(continued)

Three Programming Contructs

(continued)2. Selection

Controls the flow of execution down one of two or more paths, depending on the result of a logical test.

If – then – [else – then]

If (temperature < 50)

Wear long pants

Else

Wear shorts

Page 16: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

Three Programming Contructs

(continued)

Three Programming Contructs

(continued)2. Selection - Switch

Switch (temperature / 10)Case 0:Case 1:Case 2:Case 3:Case 4: Wear long pants breakCase 5: Wear zip-offs breakDefault Wear shorts

Page 17: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

Three Programming Contructs

(continued)

Three Programming Contructs

(continued) Iteration

A block of code is required to be executed continually until a condition is met

For While

Pre condition Do While

Post Condition

Page 18: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

Lempel Ziv Welch - LZW Lempel Ziv Welch - LZW

Used in GIF, TIFF-LZW, PostScript, Portable Document Format (PDF), V.42bis, compress

U.S. LZW patent (Unisys) expired June 20, 2003.CompuServe released GIF as a free and open

specification in 1987.…the reading and/or writing of GIF images requires a

license to use Unisys patented Lempel Ziv Welch (LZW) data compression and decompression technology… form Unisys

Page 19: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

LZWLZW

LZW starts with a 4K dictionary, of which entries 0-255 refer to individual bytes, and entries 256-4095 refer to substrings.

Each time a new code is generated it means a new string has been parsed.

New strings are generated by appending the current character/pixel color K to the end of an existing string w.

Page 20: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

LZWLZWset w = “” loop read a character/pixel K if wK exists in the table w = wK else output the code for w add wK to the table w = K endloop

Page 21: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

LZWLZWInput string: /WED/WE/WEE/WEB Character Code New code value input: Output: and associated string:/W / 256 = /W E W 257 = WE D E 258 = ED / D 259 = D/ WE 256 260 = /WE / E 261 = E/ WEE 260 262 = /WEE /W 261 263 = E/W EB 257 264 = WEB <END> B

Page 22: Images 01/29/04 Resources: Yale Web Style Guide The GIF Controversy Unisys - lzw

LZWLZWLZW applet