images 01/29/04 resources: yale web style guide the gif controversy unisys - lzw
TRANSCRIPT
Images
01/29/04Resources:Yale Web Style GuideThe GIF ControversyUnisys - 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
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)?
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
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)?
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
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?
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.
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
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
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.
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
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
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
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
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
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
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
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.
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
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
LZWLZWLZW applet