cs 101 – sept. 14 review huffman code image representation –b/w and color schemes –file size...
TRANSCRIPT
![Page 1: CS 101 – Sept. 14 Review Huffman code Image representation –B/W and color schemes –File size issues](https://reader033.vdocuments.mx/reader033/viewer/2022051216/5697bffb1a28abf838cc0f74/html5/thumbnails/1.jpg)
CS 101 – Sept. 14
• Review Huffman code
• Image representation– B/W and color schemes
– File size issues
![Page 2: CS 101 – Sept. 14 Review Huffman code Image representation –B/W and color schemes –File size issues](https://reader033.vdocuments.mx/reader033/viewer/2022051216/5697bffb1a28abf838cc0f74/html5/thumbnails/2.jpg)
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!
![Page 3: CS 101 – Sept. 14 Review Huffman code Image representation –B/W and color schemes –File size issues](https://reader033.vdocuments.mx/reader033/viewer/2022051216/5697bffb1a28abf838cc0f74/html5/thumbnails/3.jpg)
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
![Page 4: CS 101 – Sept. 14 Review Huffman code Image representation –B/W and color schemes –File size issues](https://reader033.vdocuments.mx/reader033/viewer/2022051216/5697bffb1a28abf838cc0f74/html5/thumbnails/4.jpg)
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
![Page 5: CS 101 – Sept. 14 Review Huffman code Image representation –B/W and color schemes –File size issues](https://reader033.vdocuments.mx/reader033/viewer/2022051216/5697bffb1a28abf838cc0f74/html5/thumbnails/5.jpg)
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
![Page 6: CS 101 – Sept. 14 Review Huffman code Image representation –B/W and color schemes –File size issues](https://reader033.vdocuments.mx/reader033/viewer/2022051216/5697bffb1a28abf838cc0f74/html5/thumbnails/6.jpg)
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
![Page 7: CS 101 – Sept. 14 Review Huffman code Image representation –B/W and color schemes –File size issues](https://reader033.vdocuments.mx/reader033/viewer/2022051216/5697bffb1a28abf838cc0f74/html5/thumbnails/7.jpg)
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
![Page 8: CS 101 – Sept. 14 Review Huffman code Image representation –B/W and color schemes –File size issues](https://reader033.vdocuments.mx/reader033/viewer/2022051216/5697bffb1a28abf838cc0f74/html5/thumbnails/8.jpg)
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
![Page 9: CS 101 – Sept. 14 Review Huffman code Image representation –B/W and color schemes –File size issues](https://reader033.vdocuments.mx/reader033/viewer/2022051216/5697bffb1a28abf838cc0f74/html5/thumbnails/9.jpg)
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
![Page 10: CS 101 – Sept. 14 Review Huffman code Image representation –B/W and color schemes –File size issues](https://reader033.vdocuments.mx/reader033/viewer/2022051216/5697bffb1a28abf838cc0f74/html5/thumbnails/10.jpg)
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
![Page 11: CS 101 – Sept. 14 Review Huffman code Image representation –B/W and color schemes –File size issues](https://reader033.vdocuments.mx/reader033/viewer/2022051216/5697bffb1a28abf838cc0f74/html5/thumbnails/11.jpg)
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
![Page 12: CS 101 – Sept. 14 Review Huffman code Image representation –B/W and color schemes –File size issues](https://reader033.vdocuments.mx/reader033/viewer/2022051216/5697bffb1a28abf838cc0f74/html5/thumbnails/12.jpg)
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
![Page 13: CS 101 – Sept. 14 Review Huffman code Image representation –B/W and color schemes –File size issues](https://reader033.vdocuments.mx/reader033/viewer/2022051216/5697bffb1a28abf838cc0f74/html5/thumbnails/13.jpg)
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) = ?
![Page 14: CS 101 – Sept. 14 Review Huffman code Image representation –B/W and color schemes –File size issues](https://reader033.vdocuments.mx/reader033/viewer/2022051216/5697bffb1a28abf838cc0f74/html5/thumbnails/14.jpg)
Color rep’ns
• RGB – system based on light
• CMY – based on printing
• HSB – based on art
• Indexed color – a swatch to save space
![Page 15: CS 101 – Sept. 14 Review Huffman code Image representation –B/W and color schemes –File size issues](https://reader033.vdocuments.mx/reader033/viewer/2022051216/5697bffb1a28abf838cc0f74/html5/thumbnails/15.jpg)
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) ?
![Page 16: CS 101 – Sept. 14 Review Huffman code Image representation –B/W and color schemes –File size issues](https://reader033.vdocuments.mx/reader033/viewer/2022051216/5697bffb1a28abf838cc0f74/html5/thumbnails/16.jpg)
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