Text, Sound, Image Storage & Compression
1. ASCII – American Standard Code for Info Interchange
2. Unicode
3. Sound Representation
4. Image Representation (bitmap)
5. Lossless vs Lossy Compression
6. Run Length Encoding (RLE)
ASCII – American Standard Code for Information
Interchange:
Character set consisting of 7-bit codes (128 chars)
Represents numbers and characters found on a standard
keyboard
32 Control Codes – 0 to 31
Uppercase character: 6th bit is 0
Lowercase character: 6th bit is 1
Extended ASCII uses 8-bit code (256 chars) that allow for
some characters not in standard English and some
graphical/mathematical symbols
Disadvantages:
o Only English characters
o Diff ASCII code for Windows and DOS
Unicode
Universal standard that covers all languages and all writing
systems
More efficient coding system than ASCII
Uniform encoding – each character is either 16 or 32 bits
Each 16- or 32-bit value always represents the same
character
Parts of the code are reserved for the user to add their own
characters and symbols
Sound Representation
Sound waves (analogue) have Frequency, Amplitude and
Wavelength
Sound waves are sampled at regular time intervals
Sampling Resolution: number of bits per sample (aka Bit
Depth)
Sampling Rate: number of sound samples taken per second
(Hz)
Greater sampling rate/sampling resolution -> more accurate
sound
Benefits and Drawbacks of larger sound sampling resolution:
Benefits Drawbacks
Larger dynamic range Larger file size
Better sound quality Longer to transmit files
Less sound distortion Needs greater processing
power
Calculating Sound File Size:
Sample Rate (Hz) x Sample Resolution (bits) x Length
(seconds)
[for stereo file: whole thing x 2]
Representing Bitmap Images
BMP images are made of pixels (picture elements)
Each pixel represented by a binary number
So, a bitmap image is a series of binary numbers
Colour depth: number of bits used to represent each colour
o 8-bit colour depth: 256 colour options
o 1 bit per pixel: B/W image
o 2 bits per pixel: 4 colours
o 3 bits per pixel: 8 colours
Modern computers have 24-bit colour depth (16 million
colours)
Image Resolution: number of pixels that make up an image
Higher resolution:
o Clearer image
o Larger file size
o Longer to transfer/download image
Calculating Image File Size:
Length (pixels) x Height (pixels) x Colour Depth (bits)
Lossless VS Lossy Compression
Lossless Lossy
Data from the original file can Eliminates unnecessary data
be reconstructed from the file
Useful when all data in a file is Original file cannot be
needed reconstructed
None of the original detail is Loss of detail
lost
Smaller than lossless files
MP3, MP4, JPEG
Lossy: Examples
1. MP3:
Audio files
Reduces file size by 90%
Removes sounds outside of human ear range
If multiple sounds are played together, then only the
louder sound is played. Softer sound is eliminated
2. MP4:
Works similar to MP3, but can store multimedia – videos
with audio
3. JPEG:
Compresses images
Reduces colour shades which the human eye cannot
differentiate between properly
Splits images into 8x8 pixel blocks, allowing for certain
info to be removed when compressing
Lossless: Examples
Run Length Encoding (RLE):
Repeated strings of adjacent, identical data are compressed
A repeating string is encoded into:
o First value – represents number of identical data items
o Second value – represents ASCII or keyboard code of the
character
A ‘flag’ is used preceding data to indicate that what follows is
repeating units