Last time - University of Rhode Island

Download Report

Transcript Last time - University of Rhode Island

Last time
•3 main components to a computer
system
•Types of computers
•Talked about software – task oriented
•What are some kinds of data that a
computer works with?
Binary Data
• Binary is what HOW the data is
represented.
• Binary refers to 0s and 1s
• Binary number system
• Why do we use binary number
system in a computer system?
• Size of data
– For every byte, there are 8 bits
– Bit = 0 or 1
– Byte = 8 bits
How we measure bytes?
•
•
•
•
•
Use the prefix:
Kilo
Mega
Giga
tera
• A computer has a 20 gig hard drive = about 20 billion
bytes
What a byte can represent:
• The same byte 01000011 can represent
multiple things:
• The number 67
• The letter ‘C’
• A small fraction of a sound, like a song
(many sound parts make up the song)
• A small pixel in a graphic or video (many
dots make up the picture)
• A small step in a computer program
• What is this language?
What is ASCII?
• What does it stand for?
• Definition:
• How it works – the translation
Benefits of ASCII
•low susceptibility to viruses or
worms to the text only format.
•No variance in binary
representation of data (global)
Bits and Bytes
• We can count in binary
0 = 00000000
1 = 00000001
2 = 00000010
3 = 00000011
6 = 00000110
9 = 00001001
10 = 00001010
Etc…
Representing Data In Bytes
characters
• Translate binary to a word in English
GRAPHICSColor Representation
• In simple graphics a byte can
represent a single pixel
• grayscale imagery
• 1 byte can hold 256 differ shades of
gray
White = 00000000
Black = 11111111
Color Representation–
ASCII
Modern video games and colorful
graphics use several bytes for each pixel
(Nintendo 64 uses 8 bytes = 64 bits for
each pixel to get a huge array of possible
colors).
Pictures
• Num of bytes per pixel matters!
– Why do you think that is?
Bit Map
What is a bit map?
Why do we care?
Formats for differ images
• For graphics, there are several
standards or formats for pictures.
.JPG & .GIF
• The two most common by far are
GIF and JPG files
• Both of these formats encode
static bitmap images.
• Why do we see so much of these
formats?
.JPG & .GIF differences
• In a bitmap image, the image file
has to define the exact color of
every pixel in the image
• For example, a bitmap on the web
is (typical) 400 by 400 pixels.
• What problems do you see with
this?
Compression
• When downloading files off the Internet,
you've probably encountered ZIP files
– Suffit for MAC OS users, WinZip for Windows users
– Both expand/compress files on command without
compromising the integrity of the original file or end
result
• This compression system is a very
handy invention
• Why is it important to compress files?
• How it works:
– Finds redundancy and eliminates it– Most
types of computer files are fairly redundant
– In John F. Kennedy's 1961 inaugural address,
he delivered this famous line:
– "Ask not what your country can do for you -ask what you can do for your country.“
– "ask" appears two times
– "what" appears two times
– "your" appears two times
– "country" appears two times
– "can" appears two times
– "do" appears two times
– "for" appears two times
– "you" appears two times
File compression uses an adaptive dictionarybased algorithm to shrink files
–
Creates a new local dictionary, and uses a
number system to identify info.
Dictionary
1.
2.
3.
4.
5.
6.
7.
8.
ask
what
your
country
can
do
for
you
new phrase:
"1 not 2 3 4 5 6 7 8 -- 1 2 8 5 6 7 3 4"
When sending/compressing
file, the actual dictionary file
is saved along with the new
phrase representation.
.GIF File Compression
• In a GIF image, the number of colors
is reduced to 256 and then "runs" of
same-color pixels are encoded in a
color+numberOfPixels format.
• .GIF’s algorithm
• example
JPG File Compression
• Different kind of algorithm
(mathematical formula to solving a
computer problem)
• In compressing a JPG file, JPG
plays with the quality of the file in
reducing its size.
Downside to Compression
• Quality.
• Quality can be lost since it is an
approximation of the picture which
is being saved when compressing