Upload
joshua-fox
View
216
Download
3
Embed Size (px)
Citation preview
Chapter 11
Fluency with Information Technology4th edition
by Lawrence Snyder(slides by Deborah Woodall : [email protected])
1
Its about Bits…
1 High circuit Magnetized spot bump0 Low circuit Demagnetized spot land
2
And Mostly Manipulating Bits…
• ASCII characters– Bit patterns assigned arbitrarily.– Bits are not manipulated.
• Numbers, colors, images, video– Bit patterns are not arbitrary.– Bits are manipulated with mathematics.
3
Remember the Number Systems?
• Decimal number system– We know this!– base 10– 10 symbols 0 - 9– e.g. 1,375
The place values of 1, 3 7 5 are…
103 102 101 100
And it can be written in expanded form as
(1 * 103) + (3 * 102) + (7 * 101) + (5 * 100)
• Binary number system– Remember this?– base 2– 2 symbols 0 – 1– e.g. 1001Similarly the place values of 1001
are… 23 22 21 20
And it can be written in expanded form as
(1 * 23) + ( 0 * 22) + (0 * 21) + ( 1 * 20)
4
Colors
• A color code is 3 bytes: RGB (byte 1 for Red, byte 2 for Green, byte 3 for Blue)
• 3 bytes = _________bits
• The lower the number in the byte, the lower the intensity of that color.
• The fact that a color is a group of bits means we can handle a color like a number – doing arithmetic to manipulate the color.
5
Colors
• Black Red byte Green byte Blue byte
Binary: 0000 0000 0000 0000 0000 0000Hexadecimal: 00 00 00Decimal: 0 : 0 : 0
• WhiteBinary: 1111 1111 1111 1111 1111 1111Hexadecimal: FF FF FFDecimal: 255 : 255 : 255
6
Colors
• RGB values where R = G = B are gray
• If we ADD the same value to each byte we get a lighter gray.
• If we SUBTRACT the same value from each byte we get a darker gray.
7
Adding Binary Numbers
Addition Facts
0+0 0
0+1 1
1+0 1
1+1 10
11
+111
8
Adding Binary Numbers
1 01 11 1 0 01 1 1+0 0 1 1 1 0 1 0 1 1 1 0 1 1 0 1
9
Adding to Gray
Gray: 0011 1001 0010 1001 0010 1001 +0111 1010 +0111 1010 +0111 1010Lighter Gray: 1011 0011 1011 0011 1011 0011
Look at the Moon Photo discussion in the text.
10
Overflow
• Overflow occurs when the computer does arithmetic and the answer will not fit where it needs to go.
• Software should handle overflow in a reasonable manner.
• Allowing sufficient bytes for the answer is a common way to handle it.
11
File Compression
• To compress a file means to reduce the number of bits in the file, thereby making it take up less space.
• Mathematics is used to do file compression.
• This is especially important for files downloaded over the Web, or those stored in limited space like a CD or DVD or camera memory card.
12
Sound
• Mathematics is used to compress, clean up and change sound.
• Sound is a continuous vibration causing a pressure wave.
• The input device samples the wave at regular intervals storing a long sequence of bytes in memory.
• Sampling Rate=the number of samples taken per second
13
Sound
Sound In• The sound wave is detected
by a microphone.• The microphone converts
the sound wave into an equivalent electrical wave.
• The electrical wave goes into an analog-to-digital converter for sampling.
• The binary samples go into RAM.
Sound Out• The binary samples come
from RAM.• They go into a digital-to-
analog converter.• The DAC creates an
electrical wave using interpolation.
• The electrical wave goes to a speaker which vibrates creating the sound wave.
14
Sound
MP3 (MPEG level 3) compression• One of the most popular compression
techniques for music• Removes sounds we cannot hear and noise• Resulting file is about 1/10 the size of the
original• A lossy compression technique
15
Images
An image file is a long sequence of RGB pixel data.
Mathematics is used to manipulate and compress image files.
16
Images
JPEG compression– One of the more common compression
techniques for images– Best for photos and complex graphics– The resulting file is about 1/20 the size of the
original file– Amount can be controlled– An overall lossy compression technique
17
Run-Length Compression
Which representation takes up less space?r1g1b1 r2g2b2 r2g2b2 r2g2b2 r2g2b2 r2g2b2 r2g2b2 r2g2b2
r2g2b2 r2g2b2 r2g2b2 r2g2b2 r2g2b2 r2g2b2 r3g3b3
Or
r1g1b1 [13 * r2g2b2] r3g3b3
18
Images
GIF compression• Another commonly used compression technique
for images
• A lossless compression technique
• Best for icons, cartoons, and simple graphics
• Strictly uses run-length encoding.
• PNG format may eventually replace GIF
19
Video
MPEG ( MPEG-2, MPEG-4 ) compression• A commonly used compression technique for
video
• Records differences between frames
• A lossy compression technique
20