109
The Science of Digital Media • Title: The Science of Digital Media • Author: Jennifer Burg • Publisher: Pearson International Edition • Publication Year: 2009 Course Book Details 17 March 2010 1 Metropolia University of Applied Sciences, Digital Media, Erkki Rämö, Principal Lecturer The Science of Digital Media

Course Book Details

Embed Size (px)

DESCRIPTION

The Science of Digital Media. Course Book Details. Title: The Science of Digital Media Author: Jennifer Burg Publisher: Pearson International Edition Publication Year: 2009. The Science of Digital Media. General Course Contents. Part-I: Digital Data Representation and Communication - PowerPoint PPT Presentation

Citation preview

Page 1: Course Book Details

The Science of Digital Media

• Title: The Science of Digital Media• Author: Jennifer Burg• Publisher: Pearson International Edition• Publication Year: 2009

Course Book Details

17 March 2010 1Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

The Science of Digital Media

Page 2: Course Book Details

The Science of Digital Media

• Part-I: Digital Data Representation and Communication

• Part-II: Digital Image Representation• Part-III: Digital Image Processing

General Course Contents

17 March 2010 2Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

The Science of Digital Media

Page 3: Course Book Details

The Science of Digital Media

• Part-I: Digital Data Representation and Communication– Analog to Digital Conversion– Data Storage– Data Communication– Compression Methods– Standards and Standardization Organization for

Digital Media– Mathematical Modelling Tools for the Study of Digital

Media

General Course Contents

17 March 2010 3Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

The Science of Digital Media

Page 4: Course Book Details

The Science of Digital Media

• Analog versus Discrete Phenomena• Image and Sound Data represented as

Functions and Waveforms• Sampling and Aliasing• Quantization, Quantization Error, and

Signal-to-Noise Ratio

Analog to Digital Conversion

17 March 2010 4Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

The Science of Digital Media

Page 5: Course Book Details

The Science of Digital Media

• Analog Phenomena – are continuous, eg., stead stream of water, a line on

the graph or a continuous rotating dial on a radio• no clear separation between one point and the next• no separation between any two points, there is an infinite

number of other points exist

• Discrete phenomena – are clearly separated

• there is a point (in space or time)• there are neighbouring point• there is nothing between two points

17 March 2010 5Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Analog versus Discrete Phenomena (1)

Analog to Digital Conversion

Page 6: Course Book Details

The Science of Digital Media

• Analog-to-Digital conversion– Converting the continuous phenomena of images, sound

and motion into a discrete representation that can be handled by computer

• Advantages of Digital media over Analog– possibility to increase digital media resolution (due to

increase media storage and data rate in communication channels)• image and sound are communicated

17 March 2010 6Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Analog versus Discrete Phenomena (2)

Analog to Digital Conversion

Page 7: Course Book Details

The Science of Digital Media

• analog data communication is more vulnerable to noise than digital, so it looses some of its quality in transmission

• digital data is communicated entirely with 0s and 1s, error-correcting strategies is possible to ensure data is received and interpreted correctly

• digital data can be communicated more compactly than analog (excellent compression algorithms)

• provides varying bandwidth among various broadcasts to consumers

17 March 2010 7Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Advantages of Digital Media over Analog

Analog to Digital Conversion

Page 8: Course Book Details

The Science of Digital Media

• Image and Sound Data Represented as Functions and Waveforms– primary media in digital media are Images and Sound

i.e., IMAGE + SOUND = VIDEO

– both images and sound can be represented as functions visualized by their corresponding graphs

– Sound is a one-dimensional function i.e., a function with one variable as input

17 March 2010 8Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Image and Sound Data (1)

Analog to Digital Conversion

Page 9: Course Book Details

The Science of Digital Media

• Taking sound as a continuous phenomenon, then it corresponds to continuous function: where is time and is the air pressure amplitude

• The essential form of function representing sound is sinusoidal i.e., has a shape of sine wave. Consider a triangle in a Unit Cycle

17 March 2010 9Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

)(xfy ""x"" y

Image and Sound Data (2)

Analog to Digital Conversion

Page 10: Course Book Details

The Science of Digital Media

• Sines and Cosines are called Sinusoidal functions

17 March 2010 10Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

-axisx

-axisy

ch

a

A

C B

sin( ) = c/h cos( ) = a/h

Sinusoidal Functions (1)

Analog to Digital Conversion

Page 11: Course Book Details

The Science of Digital Media

• According to Pythagorean theorem the equation for Unit Cycle is

• As you move “Q” around the Unit cycle counterclockwise, angle goes from 0 to (in radians)

• For multiple times of rounds where “k” is number of times (“k” is positive in counterclockwise and negative otherwise)

17 March 2010 11Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

122 yx

2

k 2

Sinusoidal Functions (2)

Analog to Digital Conversion

Page 12: Course Book Details

The Science of Digital Media

• Generalized definitions of sine and cosine are:

• If and “k” is an integer then

17 March 2010 12Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

k 2

)cos()2cos()cos(

)sin()2sin()sin(

k

k

Sinusoidal Functions (3)

Analog to Digital Conversion

Page 13: Course Book Details

The Science of Digital Media

• Sine and cosine functions are periodic (their values cycle in regular pattern as indicated in the table below

• Angle conversion formula from Radians to Degree and vice versa: where: r = angle in radian

and d = angle in degrees

17 March 2010 13Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Angle in Radians 0

Angles in Degrees 0 30 45 60 90 120 135 150 180 210 225 240 270 300 315 330 360

Sine of Angle 0 0 0

6/ 4/ 3/ 2/ 3/2 4/3 6/5 6/7 4/5 3/4 2/3 3/5 4/7 6/11 2

21

22

23 1

23

22

21

21

22

23 1

23 2

2 21

180

d

r

Sinusoidal Functions (4)

Analog to Digital Conversion

Page 14: Course Book Details

The Science of Digital Media

• Sine and Cosine angles visualization is as indicated in the figure below:– x-axis represents the size of the angle while y-axis

represents the sine of the angle

17 March 2010 14Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Sinusoidal Functions (5)

Analog to Digital Conversion

Page 15: Course Book Details

The Science of Digital Media

• How Sinusoidal function relates to wave and thus to sound and images?

• Sound is a Mechanical Wave– it results from the motion of particles through a transmission

medium eg., the motion of molecules in air– sound cannot be transmitted through vacuum– movement associated with sound wave is initiated by a

vibration, consider a vibrating string, its wave swings left to right and vice versa

– when wave is moving from left to right, air molecules are pushed next to each other, hence pressure rises, when string moves right to left, air molecules spread out, hence pressure is reduced

17 March 2010 15Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Sinusoidal Functions – Mechanical Wave (6)

Analog to Digital Conversion

Page 16: Course Book Details

The Science of Digital Media

• The periodic changing of air pressure – high to low, high to low, etc., forms a mechanical wave

• Below is a diagram of single-frequency (440Hz) tone with no overtones, represented as a waveform

17 March 2010 16Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Sinusoidal Functions - Mechanical Wave (7)

Analog to Digital Conversion

Page 17: Course Book Details

The Science of Digital Media

• The motion of the air molecules is back and forth from left to right -> to the direction in which the wave is radiating out from string

• Longitudinal wave– A wave in which the motion of individual particles is parallel

to the direction in which energy is being transported– The wave is periodic if it repeats a pattern over time– The pattern that is repeated constitutes one cycle of the wave– Wavelength is the length (in distance) of one complete cycle– The frequency of a wave is the number of times a cycle repeats per

unit time (in the case of sound, is the rate at which air molecules that are vibrating). Its measured in cycles per second or Hertz

17 March 2010 17Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Sinusoidal Functions – Longitudinal wave (8)

Analog to Digital Conversion

Page 18: Course Book Details

The Science of Digital Media

• Abbreviations for Frequency or Sampling rate

1Hz = 1 cycle/s1KHz = 1000 Hz1MHz = 1,000,000 Hz– Period of a wave is the amount of time it takes for one cycle to

complete. Period and frequency are reciprocals of each other where T = period and f = frequency

17 March 2010 18Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Hertz kilohertz megahertz second millisecond microsecond nanosecond

Hz kHz MHz s ms nss

TfandfT 11

Sinusoidal Functions (9)

Analog to Digital Conversion

Page 19: Course Book Details

The Science of Digital Media

• Amplitude is the height of the wave• In order to create a sine function representing a sound

wave of frequency f Hz, you must convert to angular frequency first,

Where is the angular frequency in Radians/s and is frequency of a sine wave measured in Hz.– The amplitude of the wave corresponds to sound loudness

The larger to amplitude the louder the sound– Frequency of the wave corresponds to the pitch of the sound

The higher the frequency the higher-pitched the sound

17 March 2010 19Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

f 2

f

Sinusoidal Functions (10)

Analog to Digital Conversion

Page 20: Course Book Details

The Science of Digital Media

• Single-frequency tone waves can be added to form more complex waveform

• A complex waveform can be reversed by breaking it down mathematically into frequency components by a method called Fourier transform

• The simple sinusoidal waves are called the frequency components of the more complex wave

17 March 2010 20Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Sinusoidal Functions (11)

Analog to Digital Conversion

Page 21: Course Book Details

The Science of Digital Media

• Fourier transform – makes it possible to store a complex sound wave in

digital form– determine the wave’s frequency components– filters out components that are not wanted (improves

quality or compresses digital audio file)

• Sinusoidal waveforms are used to represent changing color amplitudes in digital images too

17 March 2010 21Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Sinusoidal Functions (12)

Analog to Digital Conversion

Page 22: Course Book Details

The Science of Digital Media

• Regardless of the medium, analog-to-digital requires the same two steps Sampling and Quantization

• Sampling– Chooses discrete points at which to measure a

continuous phenomenon (called signal)• For images the sample points are evenly separated in

space• For sound the sample points are evenly separated in time

– Sampling rate (or the resolution) is the number of samples taken per unit time or unit space

17 March 2010 22Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Sinusoidal Functions - Sampling (13)

Analog to Digital Conversion

Page 23: Course Book Details

The Science of Digital Media

• Quantization– Requires that each sample be represented in a fixed

number of bits, called the sample size or equivalently the bit depth

– Bit depth is for limiting precision with which each sample can be represented

17 March 2010 23Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Sinusoidal Functions - Quantization (14)

Analog to Digital Conversion

Page 24: Course Book Details

The Science of Digital Media

• Sampling– a process of converting a signal (e.g., a function of

continuous time or space) into a numeric sequence (a function of discrete time or space)

– Undersampling means the sampling rate did not keep up with the rate of change of pattern in the image or sound

• Aliasing – In digital image arises from undersampling and results in

an image that does not match the original source, it may be blurred or have a false pattern similarly for audio wave

17 March 2010 24Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Sampling and Aliasing (1)

Analog to Digital Conversion

Page 25: Course Book Details

The Science of Digital Media

• Nyquist Theorem– It specifies the sampling rate needed for a given spatial

or temporal frequency

– It states that to guarantee that no aliasing will occur, you must use a sampling rate that is greater that twice the frequency of the signal being sampled

17 March 2010 25Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Sampling and Aliasing – Nyquist Theorem (2)

Analog to Digital Conversion

Page 26: Course Book Details

The Science of Digital Media

• The Nyquist theorem applied to a single-frequency, one dimensional wave is summarized in the following equation:

where r is the minimum sampling rate that can be used in the quantization process such that the resulting digitized wave is not aliased and f is the frequency of sine wave

r is called the Nyquist frequency

• Nyquist theorem applies equally to digital images

17 March 2010 26Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

fr 2

Sampling and Aliasing – Nyquist Theorem (3)

Analog to Digital Conversion

Page 27: Course Book Details

The Science of Digital Media

• Quantization (a)– Quantization is the second step in analog-to-digital

conversion– For digital images, each sample represents a color at a

discrete point in a two dimensional image– Number of colors possible is determined by the sample

size or bit depth (color depth for images)– One bit of color per sample == two colors because a bit

has two values 0 or 1. Eight bits, then 28 = 256 colors possible, etc

17 March 2010 27Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Quantization Error and Signal-to-Noise Ratio (1)

Analog to Digital Conversion

Page 28: Course Book Details

The Science of Digital Media

• Quantization (b)– In general, if n is the number of bits used to quantize a

digital sample, then the maximum number of different values that can be represented, m, is m = 2n

– The large the bit depth, the more subtle the color changes can be in a digitized image, the bigger the file size

– For digital audio, the common sample sizes are 8 and 16 bits

17 March 2010 28Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Quantization Error and Signal-to-Noise Ratio (2)

Analog to Digital Conversion

Page 29: Course Book Details

The Science of Digital Media

• Quantization Error (a)– is the difference between the actual analog value and

quantized digital value

– the error is due either to rounding or truncation. It is sometimes considered as an additional random signal called quantization noise

17 March 2010 29Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Quantization Error and Signal-to-Noise Ratio (3)

Analog to Digital Conversion

Page 30: Course Book Details

The Science of Digital Media

• Quantization Error (b)

17 March 2010 30Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Quantization Error and Signal-to-Noise Ratio (4)

Analog to Digital Conversion

Page 31: Course Book Details

The Science of Digital Media

• Signal-to-Noise Ratio (SNR)– Is the ratio of the meaningful content of a signal versus

the associated noise• For analog is the ratio of the average power in the signal

versus the power in the noise level. Think of a signal send over a network compared to the extend in which the signal is corrupted

• For digitized image or sound, is the ratio of maximum sample value versus the maximum quantization error. The ratio depends on the bit depth. It is also called signal-to-quantization-noise ratio (SQNR)

17 March 2010 31Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Quantization Error and Signal-to-Noise Ratio (5)

Analog to Digital Conversion

Page 32: Course Book Details

The Science of Digital Media

• Is measured in terms of decibels (dB). A dB is a dimensionless unit, they cancels in division

• A dB is used to describe the relative power or intensity of two phenomena.

Where I and I0 are the intensities (power across a surface area) of two signals of sound, data signal on a communication network or output of lasers etc, measured in watts

17 March 2010 32Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

II

dB0

10log101

Signal-to-Quantization-Noise Ratio (SQNR) - 1

Analog to Digital Conversion

Page 33: Course Book Details

The Science of Digital Media

• Another definition for decibels is:

Where E and E0 are amplitude, potential or pressure in volts

• The two definitions are equivalent, take the relationship between power I, potential E and resistance R

17 March 2010 33Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

EE

dB0

log201

RI E

2

Signal-to-Quantization-Noise Ratio (SQNR) - 2

Analog to Digital Conversion

Page 34: Course Book Details

The Science of Digital Media

• Assuming that R is constant for the two signals, then

17 March 2010 34Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

EE

E

E

IR

RI2

0

2

102

0

2

100

10logloglog 101010

EE

E E

010

2

10loglog 20

0

10

Signal-to-Quantization-Noise Ratio (SQNR) - 3

Analog to Digital Conversion

Page 35: Course Book Details

The Science of Digital Media

• Using the second definition of decibels, SQNR applies to linearly quantized samples

• The sample values range from with ‘n’ bits for quantization

•Audio signal in sine wave goes from positive to –negative values

•Maximum quantization error is half a quantization level

17 March 2010 35Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

12211 nn

to

Signal-to-Quantization-Noise Ratio (SQNR) - 4

Analog to Digital Conversion

Page 36: Course Book Details

The Science of Digital Media

• Signal-to-quantization-noise ratio (SQNR)– Therefore,

In short, let ‘n’ be the bit depth of digitized media file (e.g., digital audio) then SQNR is:

17 March 2010 36Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

21

20max

max20 2loglog

1

1010

n

erroronquantizati

valuenquntizatioSQNR

2log10

20n

SQNR

Signal-to-Quantization-Noise Ratio (SQNR) - 5

Analog to Digital Conversion

Page 37: Course Book Details

The Science of Digital Media

• Signal-to-quantization-noise ratio (SQNR)

• SQNR is directly related to Dynamic range

• Dynamic range is the ratio of the largest-amplitude sound(or color, for digital images) and the smallest that can be represented with a given bit depth.

17 March 2010 37Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Signal-to-Quantization-Noise Ratio (SQNR) - 6

Analog to Digital Conversion

Page 38: Course Book Details

The Science of Digital Media

• Digital media requires the handling of large amount of data– See example of File sizes for Uncompressed Digital Image,

Audio and Video in the table below

17 March 2010 38Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Image File Audio File Video FileResolution: 1024 pixels x 768 pixelsTotal Number of Pixels: 786,432Color mode: RGBBits per pixel: 24 (i.e., 3 bytes)Total number of bits: 18,874,368 (=2,359,296 bytes)File size: 2.25 MB

Sampling rate: 44.1 kHz (44,100 samples per second)Bit depth: 32 bits per sample (16 for each of two stereo channels) (i.e., 4 bytes)Number of minutes: oneTotal number of bits: 84,672,000(=10,584,000 bytes)File size: 10.09MBData rate of the file: 1.35Mb/s

Frame size: 720pixels x 480 pixelsBits per pixel: 24Frame rate: ~30 frames/sNumber of minutes: OneTotal image requirement: 14,929,920,000 bitsAudio requirement: 84,672,000 (see column 2)Total number of bits: 15,014,592,000(=1,876,824,000 bytes)File size: >1.7 GBData rate of the file: 238.65 Mb/s

Digital Media Versus Amount of Data (1)

Data Storage

Page 39: Course Book Details

The Science of Digital Media

• Table below shows common abbreviations for data sizes

17 March 2010 39Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

kilobyte megabyte gigabyte kilobit megabit gigabit terabit terabyte

kB MB GB kb Mb Gb Tb TB

For memory and file sizes assume the following

1 byte = 8 bits1 kB = 210 bytes1 MB = 220 bytes 1 GB = 230 bytes1 TB = 240 bytes

= 1024 bytes= 1,048,576 bytes= 1,073,741,824 bytes= 1,099,511,627,776 bytes

kb, Mb, Gb and Tb are defined analogously

Digital Media Versus Amount of Data (2)

Data Storage

Page 40: Course Book Details

The Science of Digital Media

• Storage media and their capacity

17 March 2010 40Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Storage Medium Maximum Capacity

Portable Media

CD (Compact Disk) 700 MB

DVD (Digital Versatile Disk or Digital Video Disk), standard one sided

4.7 GB standard; 8.5GB dual-layered

DVD Video or high Capacity 17-27 GB

Memory stick or card 8 GB

HD-DVD (High Definition DVD), Standard one sided

15 GB standard; 30 GB dual-layered

Blue-ray Disk 25 GB standard; 50 GB dual-layered

Flash drive 64 GB

Permanent Media

Hard Disk Drive 1 terabyte (1000 GB)

Digital Media Versus Amount of Data (3)

Data Storage

Page 41: Course Book Details

The Science of Digital Media

• Confusion between the prefixes kilo-, mega-, and giga-eg., for the case of Hertz:kilo- means 103 = 1000mega- means 106 = 1,000,000giga- means 109 = 1,000,000,000

• In the case of data storage kilo- means 103 or 210 mega- means 106 or 220

giga- means 109 or 230

17 March 2010 41Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Digital Media Versus Amount of Data (4)

Data Storage

Page 42: Course Book Details

The Science of Digital Media

• Manufacturers wants to make their storage media look larger, so they generally use the power of 10

• While many computers will give file sizes defined in powers of 2

17 March 2010 42Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Digital Media Versus Amount of Data (5)

Data Storage

Page 43: Course Book Details

The Science of Digital Media

• The importance of Data Communication in the study of Digital Media– Digital files are typically very large, can be stored in CDs

and DVDs, send them in email, and post them on web pages -> consideration to transmission media

– Sound and video are time-based media, they require large amount of data.• Capturing and transmitting in real-time require data

transmission rate is the same as that of which data is played• Consideration is taken to bandwidth and data rate

– Digital communication media at home and offices• Cellular phones, digital cable, digital television, HDTV and more

17 March 2010 43Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Data Communication

Data Communication and Digital Media

Page 44: Course Book Details

The Science of Digital Media

• Whether data is in analog or digital, they both need a communication channel from sender to receiver e.g., – Land-based or cellular telephone – Shortwave or regular radios

• Cable• terrestrial or satellite television • wired or wireless computer networks

17 March 2010 44Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Data Communication

Analog Versus Digital Data Communication (1)

Page 45: Course Book Details

The Science of Digital Media

• How do you know which communication are being send digitally? (a)– Transmission medium does not determine the form of

data, digital or analog• Copper wire – can transmit both analog and digital data (eg.,

telephone or computer networks)• Coaxial cable (e.g., television)• Optical fiber (e.g., high-speed computer networks)• Free space (e.g., radio or television)

– Copper wire, coaxial cable and optical fiber all require a physical line between the sender and receiver

17 March 2010 45Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Data Communication

Analog Versus Digital Data Communication (2)

Page 46: Course Book Details

The Science of Digital Media

• How do you know which communication are being send digitally? (b)– Across copper wire or coaxial cable, data can be transmitted

by changing voltages– Through Optical fiber, data can be communicated by a

fluctuating beam of light– Free space, data can be communicated through

electromagnetic waves sent by satellite or radio transmission

• It is the representation of data, not the transmission medium that determine if communication is analog or digital

17 March 2010 46Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Data Communication

Analog Versus Digital Data Communication (3)

Page 47: Course Book Details

The Science of Digital Media

• What is the difference between ways analog and digital data are transmitted across a network? (a)– Take analog telephone transmissions through wire to start

with– First sound is captured electronically, changes in air

pressure are tranlated to changes in voltage– For the spoken word “boo,” the voltages rise and fall as

indicated in the figure below

17 March 2010 47Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Data Communication

Analog Versus Digital Data Communication (4)

Page 48: Course Book Details

The Science of Digital Media

• What is the difference between ways analog and digital data are transmitted across a network? (b)– If the word “boo,” is digitized, it is sampled and quantized

such that data are transformed into sequence of 0s and 1s as in figure below

– Positive (voltage level) may represent 1 bit and negative(voltage level) may represent 0 bit

– Communication begins with some initial sychronization between sender and receiver

17 March 2010 48Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Data Communication

Analog Versus Digital Data Communication (5)

Page 49: Course Book Details

The Science of Digital Media

• What is the difference between ways analog and digital data are transmitted across a network? (c)– A sending device maintains a steady voltage for a fixed amount of

time to send each bit– The receiving device samples the transmission at evenly-spaced

points in time to interpret whether 0 or 1 has been sent– Varying the voltage levels in the manner just described is called

Baseband transmission– The line of communication between sender and receiver is called a

Baseband channel– Baseband transmission is used across wire and coaxial cable,

across relatively short distances (due to noise and attenuation)

17 March 2010 49Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Data Communication

Analog Versus Digital Data Communication (6)

Page 50: Course Book Details

The Science of Digital Media

• What is the difference between ways analog and digital data are transmitted across a network? (d)– Attenuation is the weakening of a signal over time and/or

space– Modulated data transmission (or bandpass transmission)

• Is based on the observation that a continuously oscillating signal degrades more slowly and thus is better for long distance communication

– Modulated data transmission makes use of a carrier signal on which data are “written”

– Data are written on the carrier signal by means of modulation techniques

17 March 2010 50Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Data Communication

Analog Versus Digital Data Communication (7)

Page 51: Course Book Details

The Science of Digital Media

• What is the difference between ways analog and digital data are transmitted across a network? (e)– Three basic methods for modulating a carrier wave are :

• Amplitude modulation, Frequency modulation and Phase modulation

– Amplitude Modulation• The amplitude of the carrier signal is increased by a fixed

amount each time a digital 1 is communicated

– Frequency Modulation• The frequency is changed

– Phase Modulation• The phase is shifted

17 March 2010 51Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Data Communication

Analog Versus Digital Data Communication (8)

Page 52: Course Book Details

The Science of Digital Media

• What is the difference between ways analog and digital data are transmitted across a network? (f)– Figure below shows the modulation methods where digital

signal 101 is being send

17 March 2010 52Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Amplitude Modulation Frequency Modulation Phase Modulation

Data Communication

Analog Versus Digital Data Communication (9)

Page 53: Course Book Details

The Science of Digital Media

• What is the difference between ways analog and digital data are transmitted across a network? (g)– Modulated signals are not necessary digital– Bandpass tramission -> the carrier signal lies in the center of

a frequency band called a channel that is allocated for communication

– The sender and receiver both know the channel assigned to them

– The sender uses only those frequencies that lie within its channel, and the receiver listens only within that channel

17 March 2010 53Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Data Communication

Analog Versus Digital Data Communication (10)

Page 54: Course Book Details

The Science of Digital Media

• Different colors of light have different frequencies • Color of light are divided into bands or channels when

communicated along optical fiber, see figure below • The figure shows colors by their wavelength

17 March 2010 54Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

f

c

Where is Wavelength, is frequency and

is the speed of light in vacuum

f

c

Data Communication

The Spectrum of Visible Light

Page 55: Course Book Details

The Science of Digital Media

• Can be divided into frequency bands also• Both analog and digital messages can be encoded

using carrier signals in the form of light or other electromagnetic waves

• A continuously oscillating electrical voltage can also be used as a carrier signal (analog telephone to handle digital data by means of modem case)

• Modem stands for Modulator and Demodulator

17 March 2010 55Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Data Communication

Electromagnetic Waves (1)

Page 56: Course Book Details

The Science of Digital Media

• Modem takes data given to it by a computer and writes the 0s and 1s onto continuously oscillating voltage using one of the three modulation methods

• At the other end of the call another modem demodulates the signal for delivery to another computer

• Figure showing the Electromagnetic Spectrum

17 March 2010 56Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Data Communication

Electromagnetic Waves (2)

Page 57: Course Book Details

The Science of Digital Media

• Bandwidth as Maximum Rate of Change in Digital Data Communication (a)– In digital media, bandwidth refers to transmission of

discrete 0s and 1s– Transmission can be done by discrete pulses, i.e.,

discrete changes of voltages in baseband data transmission

– In case of modulated communication, • Data can be communicated by discrete changes in frequency,

amplitude or phase of a carrier signal

17 March 2010 57Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Bandwidth

Bandwidth and Digital Data Communication (1)

Page 58: Course Book Details

The Science of Digital Media

• Bandwidth as Maximum Rate of Change in Digital Data Communication (b)– How fast can the signal be changed from voltage

+V to –V and back again?– How fast can the sender change the amplitude of a

carrier signal (or the frequency or the phase)? Keeping in mind that the receiver will understand the changing signal as well!

– Example 1:

• How fast can you talk and still speak clearly? (that your friend can understand!)

17 March 2010 58Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Bandwidth

Bandwidth and Digital Data Communication (2)

Page 59: Course Book Details

The Science of Digital Media

• Bandwidth as Maximum Rate of Change in Digital Data Communication (c)– The maximum rate at which you can talk and your friend

can understand is the bandwidth of communication. • Note: this has nothing to do with the speed of sound!

– Example 2:• What if you had to send Jarkko code by means of a blinking

flashlight? How fast could you send the code?

– The speed is limited by how fast the hardware (your flashlight) can be operated and how fast your hand can click• Note: this has nothing to do with the speed of light

17 March 2010 59Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Bandwidth

Bandwidth and Digital Data Communication (3)

Page 60: Course Book Details

The Science of Digital Media

• Bandwidth as Maximum Rate of Change in Digital Data Communication (d)– Bandwidth is measured in cycles per second or Hz– A baseband transmission system with a bandwidth of

5000 Hz means it can cycle through its signal (from one voltage level to another and back again at the rate of 5000 times per second

– In general if a signal is send with two possible signal levels then:

17 March 2010 60Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

bd 2 d is the data rate, in bits/s

b is bandwidth in Hz

Bandwidth

Bandwidth and Digital Data Communication (4)

Page 61: Course Book Details

The Science of Digital Media

• Bandwidth as Maximum Rate of Change in Digital Data Communication (e)– Bandwidth is defined by how fast the signal can change– What if more than one signal level is permitted? (Instead

of having one voltage level represent 0 and the other1, you have 00, 01, 10 and 11 voltage levels)

– Therefore, each change of voltage would transmit two bits instead of one

– Multilevel Coding -> Means allowing more than two signal levels such that more than one bit can be communicated

17 March 2010 61Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Bandwidth

Bandwidth and Digital Data Communication (5)

Page 62: Course Book Details

The Science of Digital Media

• Bandwidth as Maximum Rate of Change in Digital Data Communication (f)– Assuming that a signal is sent with “k” possible signal

levels and a bandwidth of “b” Hz. Then the data rate, “d”, in bits/s is:

17 March 2010 62Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

kbd log2

2

Bandwidth

Bandwidth and Digital Data Communication (6)

Page 63: Course Book Details

The Science of Digital Media

• Bandwidth as Maximum Rate of Change in Digital Data Communication (g)– Figure showing an example of data rate as determined by

number of signal levels

17 March 2010 63Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

With k signal level, log2k bits are transmitted with each signal.

Bandwidth

Bandwidth and Digital Data Communication (7)

Page 64: Course Book Details

The Science of Digital Media

• Bandwidth of a signal (Width of a signal)– Is the difference between the maximum and minimum

frequency components of a periodic wave form– Generally:

– The width of a signal must fit within the width of the channel on which it is transmitted otherwise some information will be lost

17 March 2010 64Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

ffwminmax

Where is the Width of a signal

is the frequency of the highest-frequency component

is frequency of the lowest-frequency component

wfmax

fmin

Bandwidth

Bandwidth In terms of Frequency (1)

Page 65: Course Book Details

The Science of Digital Media

• Data is communicated via airwaves through particular channel, i.e., band of frequencies

• The range of frequencies allocated to a band constitutes the bandwidth of a channel( or width of a channel because it correlates with width of signal)

• Bandwidth in this case refers to data that are transmitted by means of a carrier signal of a given frequency that lies at the center of channel

17 March 2010 65Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Bandwidth

Bandwidth In terms of Frequency (2)

Page 66: Course Book Details

The Science of Digital Media

• The Federal Communication Commission allocates channels of an appropriate bandwidth, enough to accommodate the type of communication, see next table

17 March 2010 66Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Frequency Bands for Radio and Television

Radio Television

AM, 535 kHz to 1.7 MHzshortwave radio, 5.9 MHz to 26.1 MHzCB radio, 26.96 MHz to 27.41 MHzFM radio, 88 MHz to 108 MHz, allocated in 200 kHz channels

54 to 88 MHz for channels 2 to 6174 to 216 MHz for channels 7 to 13470 to 890 MHz for UHF channels 14 to 83

Bandwidth

Bandwidth In terms of Frequency (3)

Page 67: Course Book Details

The Science of Digital Media

• Also carrier signal that lies at the center of channel caries data (analog or digital data)

• Modulation is applied to carrier signal so that it contains data, regardless of whether it is analog or digital

• Modulation adds frequency component called sidebands to the original carrier signal

• Sidebands must lie within the designated channel• The bandwidth of a channel affects the amount of

information that can be communicated

17 March 2010 67Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Bandwidth

Bandwidth In terms of Frequency (4)

Page 68: Course Book Details

The Science of Digital Media

• How is an appropriate bandwidth determined for AM radio, FM radio, Television and digital HDTV?

• What makes 10kHz (for AM radio), 200kHz (for FM radio), 6MHz(for television) and 20MHz (for digital HDTV), the right size?

• How does modulation of a carrier signal give rise to sidebands?

• What are the frequencies of these sidebands and their effect to bandwidth requirements for channels?

• These questions will be examined in more details in Chapter 6

17 March 2010 68Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Bandwidth

Bandwidth In terms of Frequency (5)

Page 69: Course Book Details

The Science of Digital Media

• Taking the first Bandwidth definition– The maximum rate of change of a signal, as a property of

the communication system on which the signal is being sent

• The definition is closely related to data rate or bit rate

• Bandwidth is often loosely used as a synonym for data rate or bit rate

• But we are going to distinguish between the terms

17 March 2010 69Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Data Rate

Bit Rate (1)

Page 70: Course Book Details

The Science of Digital Media

• Bandwidth is measured in cycles per second – Hertz• Data rate is measured in bits per second – more

precisely,– in kilobits per second (kb/s)– in kilobytes per second (kB/s)– megabits per second (Mb/s)– megabytes per second (MB/s)– gigabits per second (Gb/s)– gigabytes per second (GB/s)

17 March 2010 70Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Data Rate

Bit Rate (2)

Page 71: Course Book Details

The Science of Digital Media

• Bandwidth and data rate are related by the equation

• d is a theoretical data rate – a maximum that is not achievable in reality

• The actual amount of data that can be sent per unit time is limited by the noise that is present in any communication system

• No signal can be send with a perfect clarity over an indefinite span of space and time

• Some amount of noise is introduced by electromagnetic interference

17 March 2010 71Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

kbd log2

2

Data Rate

Bit Rate (3)

Page 72: Course Book Details

The Science of Digital Media

• If too much noise is introduced, the receiver cannot always interpret the signal correctly

• A refinement of the relationship between data rate and bandwidth is given by Shannon’s Theorem, quantifies the achievable data rate for a transmission system that introduces noise:

• Note that is another application of signal-to-noise ration discussed earlier

17 March 2010 72Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

p

sbc 1log2

Where is a measure of the signal power is a measure of the noise power

sp

ps

Data Rate

Bit Rate (4)

Page 73: Course Book Details

The Science of Digital Media

• Data rate is important in three aspects of digital media– Communicating the data– Capturing the data– In case of audio and video playing it

• No one wants to wait an unreasonable length of time to transfer pictures, sound and video from one place to another

• Because digital data are large, compression becomes important aspect to achieve the three important aspects of data rate above

17 March 2010 73Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Data Rate

Bit Rate (5)

Page 74: Course Book Details

The Science of Digital Media

• Baud rate has a close meaning to bandwidth and bit rate

• Is the number of changes in the signal per second, as a property of sending and receiving devices, measured in cycles per second, Hertz

• Under this definition baud rate is synonymous with bandwidth, not bit rate

17 March 2010 74Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Data Rate

Baud Rate (1)

Page 75: Course Book Details

The Science of Digital Media

• The main difference to bandwidth is that baud rate is usually used to refer to sending and receiving devices, whereas bandwidth has other meanings related to frequencies over the airwaves

• A device like a modem can have a maximum baud rate as well as an actual baud rate. The actual baud rate is the rate agreed upon between sender and receiver for a particular communication

17 March 2010 75Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Data Rate

Baud Rate (2)

Page 76: Course Book Details

The Science of Digital Media

• What is often reported as a baud rate is really a bit rate. (But bit rate is generally what you want to know anyway, so no harm done). To be precise, baud rate and bit rate are related by the equation:

17 March 2010 76Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

kbd log2

2

Data Rate

Baud Rate (3)

Page 77: Course Book Details

The Science of Digital Media

• Digital media files are usually very large, they need to be made smaller – compressed

• Without compression -> storage capacity will not be enough and communicating them across network will be difficult

• On the other hand, you do not want to sacrifice the quality of your digital images, audio and video in the compression

• Fortunately, the size of the digital files can be reduced significantly with little or no perceivable loss of quality

17 March 2010 77Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Types of Compression (1)

Page 78: Course Book Details

The Science of Digital Media

• Compression algorithms can be divided into two basic types:– Lossless Compression

• No information is lost between the compression and decompression steps

• Compression reduces the file size to fewer bits.• Decompression restores the data values to exactly what

they were before the compression

17 March 2010 78Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Types of Compression (2)

Page 79: Course Book Details

The Science of Digital Media

• Compression algorithms can be divided into two basic types:– Lossy Compression

• Sacrifices some information• The algorithm is designed so that the information lost is

not generally important to human perception– In image files, it could be subtle changes in color that the eyes cannot

detect– In sound files, it could be the frequencies that are imperceptible to the

human ear

17 March 2010 79Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Types of Compression (3)

Page 80: Course Book Details

The Science of Digital Media

• Other labels given to types of compression algorithms are:– Dictionary-based compression– Entropy compression– Arithmetic compression – Adaptive compression– Differential compression methods

17 March 2010 80Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Types of Compression (4)

Page 81: Course Book Details

The Science of Digital Media

• Dictionary-based compression method (e.g., LZW compression)– Uses a look-up table of fixed-length codes– One code word may correspond to a string of symbols

rather than to a single symbol in the file being compressed

• Entropy compression (a)– Uses a statistical analysis of the frequency of symbols

and achieves compression by encoding more frequently-occuring symbols with shorter code words, with one code word assigned to each symbol

17 March 2010 81Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Types of Compression (5)

Page 82: Course Book Details

The Science of Digital Media

• Entropy compression (b)– Shannon-fano and Huffman encoding are examples of

Entropy compression

• Arithmetic Encoding – Benefits from similar statistical analysis, but encodes an

entire file in a single code word rather creating a separate code for each symbol

• Adaptive Method (a)– Gains information about the nature of the file in the

process of compressing it, and adapt the encoding to reflect what has been learned at each step

17 March 2010 82Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Types of Compression (6)

Page 83: Course Book Details

The Science of Digital Media

• Adaptive Method (b)– LZW compression is by nature adaptive because the

code table is created “on the fly” during compression and decompression

– Huffman encoding can be made adaptive if frequency counts are updated as compression proceeds rather than being collected beforehand, it can adapt the nature of data as it reads

17 March 2010 83Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Types of Compression (7)

Page 84: Course Book Details

The Science of Digital Media

• Differential Encoding– Is a form of lossless compression that reduces file size

by recording the difference between neighbouring values rather than recording the values themselves

– Differential encoding can be applied to digital images, audio or video

17 March 2010 84Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Types of Compression (8)

Page 85: Course Book Details

The Science of Digital Media

• The Compression rate of the compression algorithm– Is the ratio of the original file size “a” to the size

of compressed file “b” expressed as a:b.– Alternatively you can speak of the ratio of b to a

as a percentage

17 March 2010 85Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

The Compression Rate

Page 86: Course Book Details

The Science of Digital Media

• Is a simple example of lossless compression• Is used in image compression e.g., .bmp suffix ( a

Microsoft version of bitmap image files uses RLE)• How RLE Works? (a)– An image file is stored as a sequence of color values for

consecutive pixel locations across rows and down columns

– If the file is in RGB color mode –> three bytes per pixel, one for each of the Red, Green and Blue color channels

17 March 2010 86Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Run-Length Encoding (RLE) - 1

Page 87: Course Book Details

The Science of Digital Media

• How RLE Works? (b)– If the file is grayscale -> one byte per pixel– For simplicity a grayscale file is used for this

demonstration of RLE– Each pixel position is encoded in one byte, it represents

one of the 256 grayscale values (28=256 different things)

– Grayscale image file consists of a string of numbers each of them between 0 and 255

17 March 2010 87Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Run-Length Encoding (RLE) - 2

Page 88: Course Book Details

The Science of Digital Media

• How RLE Works? (c)– Assume that image has a dimension of 100 x 100 for a

total of 10,000 pixels– Assume also that the pixels are stored in row-major

order (values from a whole row are stored from left to right in each row)

– These rows will consists of strings of repeated grayscale values

17 March 2010 88Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Run-Length Encoding (RLE) - 3

Page 89: Course Book Details

The Science of Digital Media

• How RLE Works? (d)– RLE uses more concise way to store repeating grayscale

values as number pairs (c,n) instead of storing each of the 10,000pixel as an individual value

– Assume the first 20 pixels in the 10,000 pixel grayscale image file are: 255 255 255 255 255 255 242 242 242 242 238 238 238 238 238 238 255 255 255 255

– The RLE of this sequence will be (255,6), (242,4), (238,6), (255,4)

17 March 2010 89Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Run-Length Encoding (RLE) - 4

Page 90: Course Book Details

The Science of Digital Media

• How RLE Works? (e)– Number of bytes needed to store the RLE encoded

version of this line of pixels is: 20pixel x 1byte/pixel = 20 bytes

– The formula for figuring out how many bytes you need to represent a number that can be anywhere between 0 and r is:

17 March 2010 90Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

8

1log2r

b Where r is the largest run of colors, run is a continuous sequence of the same colorb is the number of bytes

Compression Methods

Run-Length Encoding (RLE) - 5

Page 91: Course Book Details

The Science of Digital Media

• How RLE Works? (f)– RLE is a simple algorithm that gives acceptable results

on some types of images with no risk of loss of quality– The file will still have precisely the same values for the

pixels after the file is encoded and decoded– The encoded values are just represented in a way that is

potentially more concise– Lossless compression algorithms are applied in

situation where loss of data cannot be tolerated

17 March 2010 91Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Run-Length Encoding (RLE) - 6

Page 92: Course Book Details

The Science of Digital Media

• How RLE Works? (g)• gzip and copress (On the Unix platform), • pkzip and winzip (on the Windows platform) are example of

tools that employ lossless compression algorithm

– RLE is not very effective for sound files – Image file format that offer lossless compression such

as LZW are PNG and TIFF– Lossless compression can also be used as one step in a

more complex algorithm that does include lossy steps, e.g., Huffman encoding in one step during the JPEG compression algorithm

17 March 2010 92Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Run-Length Encoding (RLE) - 7

Page 93: Course Book Details

The Science of Digital Media

• Claude Shanno’s work in information theory sheds light on the limits of lossless compression and methods for achieving better compression rates with entropy encoding

• Entropy encoding works by means of variable-length codes– Using fewer bits to encode symbols that occur more

frequently while using more bits for symbols that occur infrequently

17 March 2010 93Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Entropy Encoding (1)

Page 94: Course Book Details

The Science of Digital Media

• Shannon’s equation gives estimation of whether the choice of numbers of bits for different symbols is close to optimal

• The term entropy is borrowed from Physics, Shannon defines the entropy of an information source S as follows:

17 March 2010 94Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

ii

i ppSH

1log)( 2

Where S a string of symbols Is the frequency of the ith symbol in the string Can equivalently be defined as the probability that the ith symbol will appear at a given position in the string

ip

ip

Compression Methods

Entropy Encoding (2)

Page 95: Course Book Details

The Science of Digital Media

• Example: Take an image which has exactly 256 pixels in it each pixel of different color, then frequency of each color is 1/256

• Using Shannon’s equation, the average number of bits needed to encode each color is 8

• For images with many instances of some colors, but only a few instances of others, refer to the book

17 March 2010 95Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

255

0

255

02

255

02 88

256

1256log

256

1

25611

log256

1

Compression Methods

Entropy Encoding (3)

Page 96: Course Book Details

The Science of Digital Media

• For images with many instances of some colors, but only a few instances of others, see the table below

• The Shannon equation becomes

17 March 2010 96Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Color black white yellow orange red purple blue Green

Frequency 100 100 20 5 5 3 20 3

006.2075.0287.0075.0111.0111.0287.0530.0530.0

3

256log

256

3

20

256log

256

20

3

256log

256

3

5

256log

256

5

5

256log

256

5

20

256log

256

20

100

256log

256

100

100

256log

256

100

2222

2222

Compression Methods

Entropy Encoding (4)

Page 97: Course Book Details

The Science of Digital Media

• How Shannon’s Equation is applied to compression– Consider every term in the equation above individually,

the first term for black and the third term for Yellow

– The implication is that, those numbers are the optimum bits to encode that specific color information content in the image file

– But the overall minimum value for the average number of bits required to represent each symbol-instance in this file is 2.006

17 March 2010 97Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

bitsYellow

bitsBlack

678.320

256log:

356.1100

256log:

2

2

Compression Methods

Entropy Encoding (5)

Page 98: Course Book Details

The Science of Digital Media

• Shannon-Fano Algorithm– Describes one way that Shannon’s equation can be

applied for compression

– It attempts to approach an optimum compression ratio by assigning relatively shorter code words to symbols that are used infrequently, and vice versa

17 March 2010 98Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Entropy Encoding (6)

Page 99: Course Book Details

The Science of Digital Media

• One drawback of Shannon-Fano Algorithm is that the optimum encoding is not possible because of the use of integer number of bits for each code

• Arithmetic encoding overcomes that because it is based on statistical analysis of frequency of symbols in a file– It encodes an entire file than (or string of symbols) as one entity

rather than creating a code symbol by symbol– String is symbols is encoded in a single floating point number

(makes it closer to optimal than Huffman encoding)– It can be applied as one step in JPEG compression of photographic

images– IBM and other companies hold patent on algorithm for arithmetic

encoding

17 March 2010 99Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Arithmetic Encoding

Page 100: Course Book Details

The Science of Digital Media

• Is a lossy method (information lost is relatively unimportant)

• The data is first transformed from one way of presenting to anather– Discrete Cosine Tranform (DCT)– Discrete Fourier Transform (DFT)

• No information is lost in the DCT or DFT• When DCT or DFT is used as one step in compression

algorithm, then it becomes possible to discard redundant or irrelevant information in later steps

• Hence reduction of the digital file size

17 March 2010 100Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Transform Encoding (1)

Page 101: Course Book Details

The Science of Digital Media

• The DCT– Applied to digital images to change their representation

from the spatial to the frequency domain– The transformation from spatial to frequency domain is

the first step in image compression– Once you have separated the high frequency

components of an image, you can remove them– High frequency components corresponds to quick

fluctuations of color in a short space, changes that aren’t easy for human to see

– This is the basis of JPEG compression

17 March 2010 101Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Transform Encoding (2)

Page 102: Course Book Details

The Science of Digital Media

• The DFT– Applied to sound– Transforming audio data from the temporal to the

frequency domain– With the frequency component separated out, it is

possible to determine which frequency mask or block out other ones and then discard the masked frequencies

– By this method, transform encoding is followed by perceptual encoding

– The result is the smaller audio file

17 March 2010 102Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Transform Encoding (3)

Page 103: Course Book Details

The Science of Digital Media

• Some compression methods are used with each other to achieve final compressed product, e.g., JPEG and MPEG compression requires DCT, run-length encoding and Huffman encoding

• Some algorithms are standardized by official committees so that the various implementations all produce files in the same format

• Patented algorithms– Commercial companies must pay a license fee to

implement and sell it in a commercial product

17 March 2010 103Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Compression Standards and Codecs (1)

Page 104: Course Book Details

The Science of Digital Media

• Two prominent examples of standardized compression algorithms are:– DV for camcorder-generated digital video – Family of MPEG algorithms

• Example of patented image compression algorithm– Arithmetic encoding

• Codecs short for compression/decompression– Are specific implementation of compression algorithm– The word Codec is reserved for audio/video compression (as

opposed to still images)– Since real-time decompression is just as important as initial

compression with these time-based media

17 March 2010 104Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Compression Standards and Codecs (2)

Page 105: Course Book Details

The Science of Digital Media

• Some codecs are offered as shareware or freeware• Most codecs are commercial products• Codecs can be embedded in image, audio or video

processing program, or can be sold and used seperately• Sorenson is an example of codec that is embedded in other

environments (e.g., QuickTime) also available in professional-grade version that runs apart from other application programs

• The professional-grade Sorenson compressor is actually a suite of codecs that includes implementations of MPEG and DV compression and the standard Sorenson codec

17 March 2010 105Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Compression Standards and Codecs (3)

Page 106: Course Book Details

The Science of Digital Media

• With most codecs the compression rate is adjusted by the user in accordance with the desired quality, up to maximum compression ability of the codec

• Compression using bits– Bit rate and compression are inversely related– Increasing the compression rate reduces the bit rate – If there are fewer bits after the data has been

compressed, then fewer bits needs to be transferred per second to play the sound or video in real time

– CD-ROM will favour a lower bit rate than DVD player

17 March 2010 106Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Compression Standards and Codecs (4)

Page 107: Course Book Details

The Science of Digital Media

• Three main types of standards– Proprietary– de facto– Official

• Proprietary Standard– Are set and patented by commercial companies– The patents of LWZ (Lempel, Zev and Welch)

compression and arithmetic encoding are examples of proprietary standards

17 March 2010 107Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Standards and Standardization Organisations (1)

Page 108: Course Book Details

The Science of Digital Media

• de facto Standard – Is used to describe a method or format that has become

the accepted way of doing things in the industry without any official endorsement

– Example TIFF files are considered by many to be the de facto standard for image files

– Nearly all the image processing programs and operating systems are equipped to handle TIFF files

17 March 2010 108Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Standards and Standardization Organisations (2)

Page 109: Course Book Details

The Science of Digital Media

• Official Standard– Are developed by large industry consortia and/or

government agencies– The organisation can exist on either a national or an

international level– The main international standardization bodies are:

• International Telecommunication Union (ITU)• International Organisation for Standards (ISO)• International Electrotechnical Commission (IEC)

17 March 2010 109Metropolia University of Applied Sciences, Digital

Media, Erkki Rämö, Principal Lecturer

Compression Methods

Standards and Standardization Organisations (2)