Download presentation

Published byEmma Lyon Modified over 4 years ago

1
Bits and Bytes There are 10 types of people in this world: those that understand binary numbers, and those that don’t. . . We’ve talked a lot about how computers work so far. Let’s recap a little – what have we talked about so far in this class? (hardware, booting, OS, XP, viruses) Well, the whole thing turns out to be a very complicated system for fiddling with ones and zeroes. It turns out that you can do a whole lot with ones and zeroes. Words, pictures, sounds, movies – can all be turned into numbers. And anything you can turn into a number, you can turn into ones and zeroes. Two values instead of our decimal digits, which can have 10 A switch has two states – on and off. Computer memory is basically made up of switches -- easy to represent 1s and 0s. But nobody is very interested in a blob of 1s and 0s – need to assemble them into larger and more interesting things. How do we use 1s and 0s to represent numbers? Words? Music? Pictures? Movies?

2
**Bits and Binary Numbers**

A bit is a Binary digIT – a digit that can have two values: one or zero. Binary numbers are composed of bits, just like decimal numbers are composed of digits 0-9 Binary numbers can be used to represent letters, numbers, pictures, sound, or just about anything. The exact same pattern of 1s and 0s might represent many different things, depending on where it is and what program is using it. For instance, the bits b could represent the number 66, or the letter ‘A’, or part of a picture, or part of a sound, or. . . The interpretation depends on the context. This includes things like the file extension, and the program that's reading the data. What does coin mean? coin – money in english, corner in french

3
**Decimal Numbers and Place Value**

Base 10 is our old friend: 5473 = (5 * 1000) + (4 * 100) + (7 * 10) + (3 * 1) Can also be written as: (5 * 103) + (4 * 102) + (7 * 101) + (3 * 100) Why do we use base 10? Because we have 10 fingers (what do the Simpsons use?) 10 is the radix – a fancy name for the base of a number system. You need 10 different symbols to represent the values in base 10. We use the digits 0-9 The rest of the meaning is conveyed by place – the 1s, 10s, 100s, etc. We could use any number as a base – 10 just happens to be convenient if you have 10 fingers.

4
Binary Numbers Base two only uses 0 and 1. The place values are powers of 2: 1, 2, 4, 8, 16, 32, 64, 128, and so forth, ad infinitum. Example: b = (1*27) + (0*26) + (0*25) + (1*24) + (0*23) + (1*22) + (1*21) + (1*20) = 128's 64's 32's 16's 8's 4's 2's 1's 1 = 151

5
**A Binary Odometer Binary: Decimal: And so on, ad infinitum. . . 1 1 2**

1 10's 1's 1 2 3 4 5 6 7 8 9 have kids with 1/0 paper – count 0 – 32 go around room from there And so on, ad infinitum. . .

6
**Example 198 = 11000110b Convert 198 to binary: 1**

198 / 128 = 1, remainder is 70 70 / 64 = 1, remainder is 6 6 / 32 = 0, remainder = 6 6 / 16 = 0, remainer = 6 6 / 8 = 0, remainder = 6 6 / 4 = 1, remainder is 2 2 / 2 = 1, remainder is 0 0 / 1 = 0 128 128's 64's 32's 16's 8's 4's 2's 1's 1 198 = b

7
**Bytes A byte is 8 bits. 8 bits can represent 256 different values.**

Computers generally use a byte or a series of bytes to represent information. 16 bits will represent 256*256=65536 different values. 24 bits will represent 256*256*256=16,777,216 different values. and so on. . . How many different values can be represented in 16 bits? 256 * 256 = 65536 Why 8 bits in a byte? Like asking why is 12 a dozen. Just something that worked out well over the years. Really became set in stone with IBM 360 computers in 1965

8
**Counting Bytes: Kilo, Mega, Giga, Tera, and Lotta**

Prefix Approximately? Abbrev. Exactly? How many bytes? Kilo Thousand (103) KB 1024 Mega Million (106) MB 1024 KB 1,048,576 Giga Billion (109) GB 1024 MB 1,073,741,824 Tera Trillion(1012) TB 1024 GB 1,099,511,627,776 Peta Quadrillion (1015) PB 1024 TB 1,125,899,906,842,624 Exa Quintillion (1018) EB 1024 PB A whole lot. . . Zetta Sextillion (1021) ZB 1024 EB Even more. . . Yotta Septillion (1024) YB 1024 ZB Fuggedabaddit. . . Giga comes from greek work gigas, for giant Tera comes from greek word teras, for monster A typical video store contains about 8 terabytes of video (Wikipedia) San Diego Supercomputer Center has a petabyte of hard disk storage and 6 petabytes of tape storage There are about 7 sextillion grains of sand on all the worlds deserts and beaches If you had a 1 kbps connection to the internet, how long would it take to transmit 1 KB of data? When you talk about speed,you talk about Bits per second, and 1 Kb isn’t 1024 bits, its So 1 KB = 1024 * 8 = 8192 Would take seconds to send 1KB If you have 20 people waiting in line at a bank, and the tellers can handle 2 people per minute, how long will it take to handle the line?

9
Hexadecimal – Base 16 An 8 bit byte is frequently shown as a pair of hexadecimal (hex) digits. 4 bits: 16 different values dec bin hex 0000b 0x0 8 1000b 0x8 1 0001b 0x1 9 1001b 0x9 2 0010b 0x2 10 1010b 0xA 3 0011b 0x3 11 1011b 0xB 4 0100b 0x4 12 1100b 0xC 5 0101b 0x5 13 1101b 0xD 6 0110b 0x6 14 1110b 0xE 7 0111b 0x7 15 1111b 0xF one byte two hex digits: 0x6A Hex is widely used to represent colors in HTML tags: color=“#00FF0E” 6 hex digits are enough to specify 16.7 million different combinations of R,G,B

10
**Decimal to Hex: Hex to Decimal:**

Convert decimal 173 to hex: 173 / 16 = 10 (0xA), remainder = 13 (0xD) 173 = 0xAD 16's 1's A D Hex to Decimal: Convert 0xBE to decimal: 0xBD = (11 * 16) + (14 * 1) 0xBE = 190 16's 1's B E

11
**Binary to Hex Example 0xDC 1 D C**

128's 64's 32's 16's 8's 4's 2's 1's 1 D C 0xDC Starting from the right-most bit, break the binary number into groups of 4 bits, and convert each group to the equivalent hex digit.

12
Encoding Text Fundamentally, computers just deal with numbers. They store letters and other characters by assigning a number for each one. Characters are generally represented in a computer as ASCII or Unicode values, where numbers are assigned to letters, digits, punctuation, etc. Binary Decimal Symbol 48 49 1 50 2 … 65 A 66 B 67 C Sample ASCII: The idea is the same as if you made up a code that says that 1 = a, 2 = b, etc Note anything interesting? Digits map to lower 4 bits Upper case, lower case 1 bit different for alphabetization What about non-western languages? Unicode – 16 bits allows 64K symbols – when upper byte 0, lower byte treated as if ASCII

13
Analog Digital We saw yesterday how you could express any number in terms of 1s and 0s – so that means if we can express anything as numbers, we can express it as 1s and 0s. So now the question is, how do we express things in terms of numbers? The analog clock is continuous. It can’t get from 1:00 to 1:01 without passing through every point between the two. It can display an infinite number of points, even if you can’t see them all. If you used a magnifying glass, you’d see it sweep past every point – it can’t skip over anything The digital clock is an approximation of the time. It goes directly from 1:00 to 1:01 – there is no in-between. (draw step graph on board) You can continue to add digits – seconds, tenths, etc – the more digits, the closer you can get. But you always lose a little information. The values are discrete – you can count how many different values it can display. An analog clock can display an infinite number of values, even if you can't see them. It's the hands that tell the time, not the numbers. shows minutes – 0-23, 0-59 – 24 * 60 -> 1440 minutes per day, sec

14
What is Sound? Sound is variations in air pressure – air moving back and forth quickly. Your ear and your brain turn these variations in air pressure into sound. Can think of sound as sculpting the air Is it discrete or continuous?

15
**How Do Speakers and Microphones Work?**

A speaker converts an electrical signal into movement of air, using magnets to push the air back and forth. When it pushes forward, the air is compressed. When it pulls back, the air is rarified, or decompressed. A microphone does the opposite – it converts the movement of air into an electrical signal. So, now we’ve gotten sound into electricity (mike) and electricity into sound (speaker) The electrical signal from a mike is still continuous -- we haven’t gotten it into 1s and 0s yet How a speaker works: windings of wire around iron core – pass current through, 1 end will be N Near another magnet – will be attracted or repulsed – switch current direction, magnet polarity reversed, switches attraction/repulsion

16
**Digital-to-Analog and Analog-to-Digital Conversion**

Converter Analog to digital converter: converts a continuous signal into a sequence of discrete values -> takes frequent measurements digital to analog converter: converts a sequence of discrete values into a continuous signal In-between – series of numbers – can save it on a disk, copy it, it, etc Digital-to-analog Converter

17
**Digitization: Turning Sound into 1s and 0s**

Sampling: Converting analog information into a digital representation by measuring the value of the analog signal at regular intervals, and encoding these integer values in digital form – 1s and 0s. Sampling rate (or frequency): How often the measurements are taken. Sampling resolution: How many different values you quantize into. 8 bit resolution allows 256 different values, 16 bit resolution allows different values. Another way to look at it is, how many marks are there on your ruler? The finer the gradations, the more accurate the representation can be. Quantization error: The difference between the actual signal level and the integer value chosen to represent it have to turn the continuous range into a set of discrete values, like the digital clock – there's no "in-between", we have to pick one of the values on the Y axis to represent the continuous value at that point. The more often you take measurements and the more precise the measurements are (note Y axis), the closer the digitized version is to the original, and the bigger the file is. . . Frequency: how often you measure Resolution: how many different values you have to represent the height The middle graph resolves the sample into one of ten values 0 – 9 The bottom graph resolves the sample into one of 36 values You have to decide how good is good enough – voice quality is not the same as music quality So, once you’ve gotten it into 1s and 0s, what can you do? Mail it, copy it, play it backwards, correct the pitch, etc – we'll see with Audacity Copy is identical to the original – it’s just a number You lose some quality when you digitize something, but once it’s digital, you won’t lose any more no matter how many copies you make it's a number – and a copy of the number is the same number Compare to a “tape of a tape of a tape” Clipping and distortion –given the bottom graph, what if a sound wave comes along that's twice as high as what's there? You don't have the range to represent it – so it gets distorted – a.k.a. clipping -- "dial goes into the red" in the recording studio dynamic range – the range of volume levels that the digitization scheme can accomodate

18
**Making Images With Ones and Zeroes**

19
**Turning Pictures into Numbers**

Pixel stands for “picture element” Pixel should be pickle? Lay out grid over picture A pixel is a single colored dot – can’t have two colors in the same pixel Decide what color best represents that square Encode color as a number The finer the grid and the more colors you use, the better the image – and the larger the digital version. Audio sampling rate -> how fine the grid is, or how many pixels (dpi) Original Image Divided into pixels Each pixel is averaged

20
**Turning Pictures into Numbers - 2**

Audio sampling resolution -> # of colors in palette, or color depth Palette: maps colors to numbers

21
**Digitizing Gone Bad. . . Not enough colors Resolution too low Original**

in palette Resolution too low Original

22
**A Possible Image File Format**

An image file could be constructed like this: First, include the palette of colors that are used Second, give the height and width in pixels Third, give the pixel data More specifically, if the image used 256 different colors: palette of 256 colors, each color 3 bytes: 768 bytes total image width in pixels – 2 bytes image height in pixels – 2 bytes 1 byte for each pixel – indicates which of the 256 colors goes in that spot So an image that's 512 x 512 pixels would be: = bytes total Think of the palette as the possible colors of all the tiles we're going to use Different images can use different palettes picking the best range of colors to represent the image is one of the challenges

23
Run-Length Encoding There are many ways to compress a bitmapped image. One simple way is run-length encoding, which is effective if an image has a lot of consecutive pixels of the same color. The image is then expressed as a series of pairs, where each pair is a pixel color, and the number of pixels in a row of that color. For the image at left, it could be W, 20, B, 3, W, 1 ,B, 1, W, 11, B, 1, etc. 16 x 16 = 256 bytes uncompressed 76 runs, 76*2 bytes = 152 bytes

24
**GIF and JPEG Compression**

JPEG (Joint Photographic Experts Group) better for photos, images with complex color schemes GIF (Graphics Interchange Format) better for line art, images with large areas of single color Compression: Since each color takes 24 bits (3 bytes), a 400x400 pixel image would be 480,000 bytes JPEG – Joint Photographic Experts Group JPEG – better for photos, more complex images – continuous tone. Not good for line art GIF – better for line art, images with large areas of single color GIF – limited to 256 different colors. JPEG – full color information (24 bits per pixel) – much more complex technique for reducing designed to exploit known limitations of the human eye, notably the fact that small color changes are perceived less accurately than small changes in brightness. Makes images smaller by throwing away some info – “lossy” compression GIFs can also have transparent areas, animation (So how do you encode movies?) Need to find out about PNG

25
**Medical Imaging – the CAT Scan**

The idea behind Computed Axial Tomography is to take X-rays from many different angles and use the information to construct an image of the object. We are essentially sampling the object with X-rays. The elements in a 3D image are called voxels.

26
A Thought Experiment. . . Imagine that you had a BB gun that always shot BBs at the same velocity, and you also had a radar gun that could measure the speed of a BB. . . You take some measurements, and discover that different substances slow the BB down by different amounts: Substance (1 cm thick): BB Slows down by: hamburger 20 m/sec jello m/sec slurpee m/sec water 5 m/sec

27
**A Thought Experiment (cont)**

Slows down hamburger 20 m/sec jello 15 m/sec slurpee 10 m/sec water 5 m/sec 100 m/sec 100 m/sec 100 m/sec B 70 m/sec A 100 m/sec C D 70 m/sec A is slurpee, B is hamburger C,D are jello Or A, B are jello C is slurpee, D is hamburger What if you took another shot through C, B and A, D? Not 1 cm distance any more. . . If first solution: AD would be 75, CB would be 65 IF second solution: AD would be 65, CB would be 75 each square is 1 cm2 – Can you determine what A, B, C, and D are? 75 m/sec 65 m/sec

28
**Computed Axial Tomography**

X-ray tube and detectors revolve around patient Detectors measure intensity of X-rays after passing through the patient Computer uses information to reconstruct a 3-D image

Similar presentations

Presentation is loading. Please wait....

OK

Copyright © 2013 Elsevier Inc. All rights reserved.

Copyright © 2013 Elsevier Inc. All rights reserved.

© 2018 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google

Ppt on forensic science laboratory Ppt on machine translation programs Ppt on asymptotic notation of algorithms book Ppt on joints of human body Simple ppt on fossil fuel for students Ppt on deforestation in india Ppt on methods of gene transfer in plants Ppt on civil engineering structures Ppt on role of water resources management Ppt on electricity and circuits