Representing Nonnumeric Data Everything is really a number
Its all 1’s and 0’s How do we represent other things? Words/Pictures/Sound? The trick is to come up with an encoding scheme…
Text To store English we need – Letters (upper case & lower) – Punctuation – Special marks (space, newline, etc…) Assigned each a number between 0 and 127 – A is 65, B is 66… – a is 97, b is 98… ASCII encoding : most popular such scheme
ASCII table DECOCTHEXBINSymbol F / A : B ; C < D = E > F ? A B C D E F G H I Partial table Full Table: A = 65 = My name: Andrew
Text Why 0-127? – Well it seemed like enough – 127 is 2^7 – the biggest number you can write with 7 binary digits. Need more characters? – Extended ASCII – 8 bits (1 byte) – 256 characters – Unicode – universal scheme – up to 4 bytes per character
Basic Types of Graphics Two basic types of 2D graphic BitmapVector
Bitmaps Image divided into pixels – Each pixel either on (1) or off (0)
Adding gray 2 digits for each square give 4 “colors” (00, 01, 10, 11)
Adding gray 2 digits for each square give 4 “colors” (00, 01, 10, 11)
Image Size Image is 2000 pixels wide & 1000 pixels tall x 1000 = 2,000,000 pixels Bits per Pixel24881 Number Colors16,777, (color)256 (grays)2 Image Size 48,000,000 bits or ~5.7 MBytes 16,000,000 bits or ~1.9 MBytes 2,000,000 bits or ~244 KBytes
Vector Art Vector images are mathematically based – Everything described as lines and curves – Shapes are filled with solid color, gradients or patterns
Computer Sounds Two approaches to representing sound as numbers: – MIDI sequences – Samples
MIDI Musical Instrument Digital Interface – Sheet music for your computer. – Does not store actual sounds – just instructions for generating the sounds. Very compact Been around since the 60’s
Samples Sounds are just pressure waves:
Samples Simulate a wave with lots of data points – Intensities at points in time – Computer reconstructs wave from points