CS 101 – Sept. 14 Review Huffman code Image representation –B/W and color schemes –File size...
-
Upload
theodora-james -
Category
Documents
-
view
219 -
download
0
Transcript of CS 101 – Sept. 14 Review Huffman code Image representation –B/W and color schemes –File size...
CS 101 – Sept. 14
• Review Huffman code
• Image representation– B/W and color schemes
– File size issues
Huffman Code
• We’re given set of letters used in message, and their frequencies.
Here’s a 2nd example:– Ex. P=5, N=10, D=10, L=15, A=20, S=20, E=30
• Arrange frequencies in order• Group the letters in pairs, always looking for the
smallest sum of frequences Create a tree!
Images
• Fundamental unit is pixel
• Size = usually 8 bits
• Scheme = grayscale, range 0-255
• Dimensions given as (horiz vert)
– Ex. 400 300 120,000 pixels
– Note that an 8-bit pixel = 1 byte
• Aspect ratio
– Ex. 4 to 3
– When changing size, ratio shouldn’t change
Properties of rep’n
• “Sampling & Quantizing”
• Resolution of image– total number of pixels in image
• Dynamic range– How many shades of gray
• To reduce file size– Reduce either # of pixels, or # bits/pixel
Resolution
• here is a (edited) digitized image with a resolution of 272 x 416
Picture resolution determines both the amount of detail as well as its storage requirements
Resolution
• notice the changes when the resolution is reduced (136 x 208)
Picture resolution determines both the amount of detail as well as its storage requirements
Resolution
• notice more changes when the resolution is reduced (68 x 104)
Picture resolution determines both the amount of detail as well as its storage requirements
Dynamic Range
• Here is an intensity or graylevel image with 256 levels (i.e., 0 to 255 scale)
DYNAMIC RANGE refers the number of values for the measuring scale used in quantizing
Dynamic Range
• Here is an intensity or graylevel image with 16 levels (i.e., 0 to 15 scale)
DYNAMIC RANGE refers the number of values for the measuring scale used in quantizing
Dynamic Range
• Here is an intensity or graylevel image with 4 levels (i.e., 0 to 3 scale)
DYNAMIC RANGE refers the number of values for the measuring scale used in quantizing
Dynamic Range
• Here is an intensity or graylevel image with 2 levels (i.e., 0 to 1 scale or a binary image)
• Dithering can help
DYNAMIC RANGE refers the number of values for the measuring scale used in quantizing
Don’t overdo it
• Too little resolution: pixelated
• Too few bits per pixel: sharp edges, cheap– Extreme case is “binary image”
• Note that n bits per pixel gives 2n values in dynamic range. 0 is black, 2n – 1 is white– Examples: n = 8, 4, 2, 1
B/W vs. Color
• B/W: usually 1 byte (8 bits) per pixel– Each pixel = grayscale number 0-255– Ex. 180 is a brighter shade of gray
• Color: usually 3 bytes (24 bits) per pixel– Each pixel has three values, each 0-255– Ex. (200, 50, 128) = ?
Color rep’ns
• RGB – system based on light
• CMY – based on printing
• HSB – based on art
• Indexed color – a swatch to save space
RGB system
• Based on primary colors for light
• Each pixel has (red, green, blue) values.
• Examplesblack = (0, 0, 0)
purple = (75, 0, 100)
white = (255, 255, 255)
• How about (x, x, x) or (0, 0, x) ?
RGB examplesColor R G B
black 0 0 0
white 255 255 255
red 255 0 0
green 0 255 0
blue 0 0 255
cyan 0 255 255
magenta 255 0 255
yellow 255 255 0