230 likes | 336 Views
Image encodings. CSC 1040. Last time: Color basics. Additive primaries Start with black background, use a hard edged brush of large diameter and set mode to “Difference” Apply red, green, blue Subtractive primaries Start with white background,
E N D
Image encodings CSC 1040 CSC 1040 - Computing with Images
Last time: Color basics Additive primaries • Start with black background, • use a hard edged brush of large diameter and set mode to “Difference” • Apply red, green, blue Subtractive primaries • Start with white background, • use a hard edged brush of large diameter and set mode to “Darken” • Apply cyan, yellow, magenta CSC 1040 - Computing with Images
red=108 green=86 blue=142 y = 9 Color:(108,86,142) Position: (12,9) x = 12 CSC 1040 - Computing with Images
Today: Pixel encodings • RGB Color • 3 colors: red, green, blue • 8 bits/color • 24 bits • Bitmap • 1 bit • Grayscale • 8 bits CSC 1040 - Computing with Images
1 byte = 8 bitsHow much can we encode in 8 bits? • Let’s walk it through. • If we have one bit, we can represent two patterns: 0 and 1. • If we have two bits, we can represent four patterns: 00, 01, 10, and 11. • If we have three bits, we can represent eight patterns: 000, 001, 010, 011, 100, 101, 110, 111 CSC 1040 - Computing with Images
In n bits, we can have 2n patterns • In 8 bits, we can have 28 patterns, or 256 • Values can be encoded as numbers from 0..255 CSC 1040 - Computing with Images
Encoding RGB • Each component color (red, green, and blue) is encoded as a single byte • Colors go from (0,0,0) to (255,255,255) • If all three components are the same, the color is in greyscale • (50,50,50) at (2,2) • (0,0,0) (at position (1,2) in example) is black • (255,255,255) is white CSC 1040 - Computing with Images
Is that enough? • We’re representing color in 24 (3 * 8) bits. • That’s 16,777,216 (224) possible colors • Our eye can discern millions of colors - so probably pretty close • Some graphics systems support 32 bits per pixel • Maybe more pixels for color, or an additional 8 bits to represent 256 levels of translucence Remember: An image that uses 24 bit color is 24 times the size of a bitmap image of the same resolution CSC 1040 - Computing with Images
File Size File size is usually measured in: bits, bytes, etc: • Byte = 8 bits • Kilobyte = 1024 bytes (= 210 bytes) • Megabyte = 1024 KB (= 210 KB or 220 bytes ) • Gigabyte = 1024 MB (= 210 MB or 230 bytes) • Terabyte = 1024 GB (= 210 GB or 240 bytes) • … CSC 1040 - Computing with Images
Image size • Image size: • Pixels (eg: 300 x 200) • Inches/centimeters (eg: 3 x 2 inches) • Resolution: #pixels/inch (eg: 100 pixels/inch) CSC 1040 - Computing with Images
Increasing Image Print Size • Image size: • Pixels (eg: 300 x 200) • Inches/centimeters (eg: 3 x 2 inches) 3 x 2 6 x 4 CSC 1040 - Computing with Images
Increasing Image Print Size Same pixels, NO Resampling • Image size: • Pixels (eg: 300 x 200) • Inches/centimeters (eg: 3 x 2 inches) • Resolution: #pixels/inch (eg: 100 pixels/inch) 3 x 2 6 x 4 50 CSC 1040 - Computing with Images
Decreasing Image Print Size • Image size: • Pixels (eg: 300 x 200) • Inches/centimeters (eg: 3 x 2 inches) • Resolution: #pixels/inch (eg: 100 pixels/inch) 3 x 2 1.5 x 1 200 CSC 1040 - Computing with Images
Changing the Number of Pixels (Resampling image) • Image size: • Pixels 300 x 200) • Inches/centimeters (eg: 3 x 2 inches) • Resolution: #pixels/inch (eg: 100 pixels/inch) 300 x 200 150 x 100 50 CSC 1040 - Computing with Images
Photoshop Image Size Menu Actual pixels Print size Lock aspect ratio Changes the actual pixels CSC 1040 - Computing with Images
Pixel encodings • RGB Color • 3 colors: red, green, blue • 8 bits/color • 24 bits • Bitmap • 1 bit • Grayscale • 8 bits CSC 1040 - Computing with Images
RGB Color File Size • Example: Image size: 300 x 200 pixels • Total pixels = 300 x 200 pixels • = 60,000 pixels • File size = 60,000 x 3 bytes (3 bytes/pixel ) = 180,000 • …..since there are 1024 bytes/KB: • = 175.8 KB • RGB color image • 24 bits (3 bytes)/pixel CSC 1040 - Computing with Images
Grayscale File Size • Example: Image size: 300 x 200 pixels • Total pixels = 300 x 200 pixels • = 60,000 pixels • File size = 60,000 bytes (1 byte/pixel ) • …..since there are 1024 bytes/KB: • = 58.6 KB • Grayscale image • 8 bits (1 byte)/pixel CSC 1040 - Computing with Images
Bitmap File Size • Example: Image size: 300 x 200 pixels • Total Pixels = 300 x 200 pixels • = 60,000 pixels • File size = 60,000 bits (1 bit/pixel ) • ….. Since there are 8 bits/byte: • File size = 60,000 / 8 bytes • = 7500 bytes • …..since there are 1024 bytes/KB: • = 7.3 KB • Bitmap image • 1 bit/pixel CSC 1040 - Computing with Images
Comparing file sizes for 300 x 200 image: • RGB Color • 3 colors: red, green, blue • 24 bits (3 bytes) • Bitmap • 1 bit • Grayscale • 8 bits (1 byte) 7.3 KB 58.6 KB 175.8 KB CSC 1040 - Computing with Images
Size of images: More Examples CSC 1040 - Computing with Images
Next Time: Image Compression • Goal: Use fewer bytes to encode the same or similar information • Reduce redundancy • Take advantage of human visual system – don’t bother differentiating things that are unnoticeable • Lose unimportant details CSC 1040 - Computing with Images