Title: Representation
1Representation
- There are 10 types of people in the worldthose
who understand binary and those who dont
2Learning Objectives
- Understand and explain how any information can be
represented as bits - Learn more general concept of representation
- Representation and interpretation are inverses
- Alternative representation schemes make some
transformations easier or harder - Can have multiple interpretations of same data
3Key concept Representation
- What does 00100100 represent?
4Terminology
- Information something that can change a persons
mind - Knowledge communicated concerning a fact,
subject, or event often contrasted to data - A pattern that conditions interaction
- Degree of choice exercised in selection
- Representation as thing (noun)
- the representation of that is 0001
- Representation as process (noun)
- representation and interpretation must be done
quickly in order to - Represent and interpret as verbs
- Represent a complicated name by its acronym
- Representation scheme
- Rules for representing (and interpreting)
5Representation
- Takes the place of the original
- Equivalent to the original, in the sense that the
original can be reconstructed from its
representation - Often the original can only be approximately
reconstructed, although it may be
indistinguishable to the user
Representation
6Representation in LMC
- Building block 3 digit numbers
- Representing numbers its easy!
- Representing instructions
- each gets a 3-digit code
- What does 901 represent in LMC?
7Representations in Digital Computers
- Computers represent all data using variable
voltage electrical signals. - We can think of them as representing this data
with on-off switches. - Bit A binary digit - it has two possible states
- On or off, true or false, 1 or 0
- Bit-string A consecutive string of bits
- Byte An 8-bit bit-string
- Word A bit-string that can be transferred and
stored as a unit.
8Decimal notation
- Decimal
- 10 possible values in each place (0-9)
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ???
- What do we do next?
- Right-most place represents how many 1s (up to
9), next place to the left for 10s (up to 9 tens,
or 90), next place for 100s (up to 900), etc. - 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, , 98, 99, 100,
etc. - For example, 506
- 6 ones, no tens, 5 hundreds
- 6 x 1 0 x 10 5 x 100
- 6 x 100 0 x 101 5 x 102
9 Binary notation
- Binary
- Only 2 possible values in each place (0 or 1)
- 0, 1, ???
- What do we do next?
- Right-most place represents how many 1s (up to
1), next place to the left for 2s (up to 1 two,
or 2), next place for 4s (up to 1 four, or 4),
etc. - 0, 1, 10, 11, 100, 101, , 1101, 1110, 1111, etc.
- For example, 110
- 0 ones, 1 two, 1 four (so 110 binary 6 decimal)
- 0 x 1 1 x 2 1 x 4
- 0 x 20 1 x 21 1 x 22
10Representing Numbers
- Converting between decimal and binary place value
system - Padding is a convention
- Why do we pad on the left?
11Tom Lehrer New Math
12ASCII what is it?
Note that this is not the only way we could
represent these symbols .this one happens to
be a standard (ANSI X3.110-1983)
- Symbol Binary
- Decimal
- 7 55 00110111
- 8 56 00111000
- 9 57 00111001
- 58 00111010
- 59 00111011
- lt 60 00111100
- 61 00111101
- gt 62 00111110
- ? 63 00111111
- _at_ 64 01000000
- A 65 01000001
- B 66 01000010
- C 67 01000011
13International Characters
- Unicode (3.0)
- 49,194 characters
- Mapped to unique codes (numbers)
- UTF-8 encoding
- Codes 0 to 127 (right-most 7 bits) map to one
byte (8 bits) each - Same encoding as ASCII
- First bit is always what?
- All other codes map to multi-byte sequences
- First bit of the leading byte in the sequence is
always what?
14Character strings
- How to represent character strings?
- A collection of adjacent words (bit-string
units) can store a sequence of letters - Notation enclose strings in double quotes
- "Hello world"
- Representation convention null character defines
end of string - Null is sometimes written as '\0'
- Its binary representation is the number 0
'H' 'e' 'l' 'l' o' ' ' 'W' 'o' 'r' 'l' 'd' '\0'
15Layered View of Representation
Textstring
Sequence of characters
Character
Bit string
16Working With A Layered View of Representation
- Represent SI540! at the two layers shown on the
previous slide. - Representation schemes
- Top layer - Character string to character
sequence Write each letter separately, enclosed
in quotes. End string with \0. - Bottom layer - Character to bit-stringRepresent
a character using the binary equivalent according
to the ASCII table provided. - Work on this individually for 3 minutes.
- Break into groups to discuss.
- Compare bit-string representations
- If you have different representations, try
interpreting a bit-string thats different from
the one you wrote.
17Solution
- SI540!
- S I 5 4 0 ! \0
- 01010011010010010011010100110100001100000010000100
000000 - The colors are intended to help you read it
computers dont care that all the bits run
together.
18Operations on ASCII strings
- Which operations are easy to implement? Why?
- Which operations are hard with this
representation? - What representation would make this easier?
19Multiple Interpretations eBays Currency
Conversion
20Multiple Interpretations eBays Currency
Conversion
GBP 1.80
2.82
1.80, GBP
1.80, GBP
21A Picture Is Worth a 1000 Words?
This information is represented in this computer,
but how?
22Representing a Picture
- Draw a grid of rectangles over the image.
- Represent each cell (pixel) with a bit-string
that represents the cells color.
23Example a smaller image
L-R (6x5)
010011111101001010010111100000
010011111101001010010111100000
T-D (5x6)
010000111110010010010010111110
010000111110010010010010111110
24Standardization
If the representation is not standardized,
the information is garbled!
Represent as 6x5
Interpretas 3x10
01001111101001010010111100000
01001111101001010010111100000
25Integrity
If the integrity of the data is not maintained,
the information is also garbled!
01001111101001010010111100000
10111111101001010010000000000
26- How to represent colors?
- 2-bits per pixel
- 422 choices
- 00 (off, off)white
- 01 (off, on)lite grey
- 10 (on, off)dark grey
- 11 (on, on)black
(This slide courtesy of Karen Markey)
27What Do You Think?
- 256 colors how many bits?
- Hint for calculating
- To figure out how many bits are needed to
represent a range of values, figure out the
smallest power of 2 that is equal to or bigger
than the size of the range. - That is, find x for 2 x gt 256
- 24-bit color how many colors?
- Hints for calculating
- 210 (10 bits) is about 1000
- 220 is 210 x 210
- 224 24 x 220
- Whats the right number of bits to use?
28Representation of picture image
Expanding a small portion of the picture, we see
that it is represented by square pixels. .300
tall by 200 wide.. .with a range of 256
intensities per pixel (8 bits 28 256)
Whats the right number of pixels per inch?
300 200 8 bits 480,000 bits (but it can be
compressed) ideas for compression?
29Vector Representation of Images
- Dont specify each pixel value
- Specify instructions for determining pixel
values, such as - Line segment from pixel (3, 7) to (105, 60)
- Triangle with vertices (3,7), (105,60), (200,10)
- Homework exercise
- Think through advantages and disadvantages of
bitmap vs. vector graphics representation
30Motion picture
A motion picture can be represented by video a
sequence of images (every tenth shown) Ideas for
compression?
31Compression
- 3 ideas
- Encode frequent symbols with fewer bits
- Encode frequent symbol sequences
- Summarize sequences inexactly
- Exercise
- How would these work for images/video?
- How would they work for text?
32Sound
- What is sound?
- What we perceive of as sound is actually our
sensory systems interpretation of very rapid
vibration of the ear drum - Sounds are transmitted as waves, a mechanical
disturbance propagating through an elastic medium - For example, sound can reach our ear drum by
traveling through air or water
See also http//entertainment.howstuffworks.com/he
aring.htm/printable and the Encyclopedia
Britannica Onlines entry for sound
33Representing Sound Graphically
- X axis time
- Y axis pressure
- A amplitude (volume)
- ? wavelength (inverse of frequency, which
determines pitch)
34Representing Sound Graphically
Low Frequency (played on a recorder)
One cycle of dominant frequency
High Frequency (played on a recorder)
One cycle of dominant frequency
35Digitizing Sound
Capture amplitude at these points
Lose all variation between data points
See Encyclopedia Brittanica article on
Analog-Digital Conversion
Zoomed Low Frequency Signal
36Reproducing Sound
Generate a wave that includes these points
37Digitizing Sound
- Exercise
- How many bits would it take to encode a Beethoven
symphony? - More or less for a newscast of same length?
- Birds chirping?
- Sample at some frequency (x times per second)
- How frequently?
- For each sample, n-bits encode amplitude
- How many bits per sample?
38Digitizing Sound
- Sample periodically
- Number of samples per second dictates range of
pitches that can be recorded - Nyquist sampling theorem says that sampling rate
should be twice highest sound frequency - Humans detect 20 20,000 Hz (or 20KHz)
- Audio CDs sampling rate is 44Kh
- For each sample, n-bits encode amplitude
- Amplitude dictates signal level
- Audio CDs bit rate is 16-bit
39Some File Formats
- Many representation schemes are associated with a
file format that we regularly use - GIF
- JPEG
- MPEG
- BMP
- PostScript
- PDF