Chapter 1 Data Representation
Chapter 1 Data Representation
SK
Data Representation
Syllabus
1.1 Number Systems
1 Understand how and why computers use x Any form of data needs to be converted to
binary to represent all forms of data binary to be processed by a computer
x Data is processed using logic gates and
stored in registers
2 (a) Understand the denary, binary and x Denary is a base 10 system
hexadecimal number systems x Binary is a base 2 system
x Hexadecimal is a base 16 system
(b) Convert between x Values used will be integers only
(i) Positive denary and p positive
ositive binary x Conversions in both directions, e.g., denary
(ii) Positive denary a and
nd positive to binary or binary to denary
hexadecimal x Maximum binary number length of 16-bit
(iii) Positive hexadecimal
hexadede
ecimal aand
nd positive
binary
Understand
3 Undersrrsstand hhow
and ow aand
nd hexadecimal
d why hex
ex
exadec m l iiss x
eccim
imal AAreas
reas wi within
ithhin ccomputer
ompuute
om ter
er sc science
cieencce tthat
hat
usedd ass a bene beneficial
bee efi method
f cial metho
ho off data
ho
hod hexadecimal is used should be identified
representation
repres senta atit onn x Hexadecimal is easier for humans to
uunderstand
un
unde
nde
ders
rsta
rs tand tthan
ta binary,
hann bi
ha b naryy, as iitt iss a sshorter
bina
ina hort
ho rtter
representation of the binary
4 (a) Add
dd
d two positive 8-bit bina
nary integers
na
binary
(b) Understand the concept of ooverflow
verflow and x An overflow error will occur if the value is
why it occurs in binary addition
adddition greater than 255 in an 8-bit register
x A computer or a device has a predefined
limit that it can represent or store, for
example 16-bit
x An overflow error occurs when a value
outside this limit should be returned
5 Perform a logical binary shift on a positive x Perform logical left shifts
8-bit binary integer and understand the x Perform logical right shifts
effect this has on the positive binary integer x Perform multiple shifts
x Bits shifted from the end of the register are
lost and zeros are shifted in at the opposite
end of the register
x The positive binary integer is multiplied or
divided according to the shift performed
+92-335-8467840
[email protected]
CS WITH
SK
x The most significant bit(s) or least significant
bit(s) are lost
6 Use two’s complement to represent positive x Convert a positive binary or denary integer
and negative 8-bit binary integers to a two’s complement 8-bit integer and
vice versa
x Convert a negative binary or denary
integer to a two’s complement 8-bit integer
and vice versa
1.2 Text, Sound & Images
1 Understand how and why a computer x Text is converted to binary to be processed
represents text and the use of character by a computer
sets, including American standard code for x Unicode allows for a greater range of
information interchange (ASCII) and characters and symbols than ASCII,
Unicode including different languages and emojis
x Unicode requires more bits per character
than ASCII
2 Understand how and w hy a computer x
hy
why A sound wave is sampled for sound to be
represents sound, including
inncl
clud
din
ing tth
h effects of
he
the converted to binary, which is processed by
samp
plee rate
the sample rat
ate a
ate nd sa
and ssample
ample rresolution
esoluutio
ioon a coompputerr
computer
x The
Thhe sample
The samp
sa mple
mp llee rate
rate is the thhe number
numb
nu berr of
of samples
sa
samp
amp
m les
taken in a second
x The sample
The samp
sa mple
mp l resolution
le res
esol
olut
ol uttioon is the
utio he nnumber
umbe
um berr of
be o b its
bits
per sample
x The accuracy of the recording and the file
size increases as the sample rate and
resolution increase
3 Understand how and why a computer x An image is a series of pixels that are
represents an image, including the effects converted to binary, which is processed by
of the resolution and color depth a computer
x The resolution is the number of pixels in the
image
x The color depth is the number of bits used
to represent each color
x The file size and quality of the image
increases as the resolution and color depth
increase
+92-335-8467840
[email protected]
CS WITH
SK
1.3 Data Storage & Compression
1 Understand how data storage is measured x Including:
bit
nibble
byte
kibibyte (KiB)
mebibyte (MiB)
gibibyte (GiB)
tebibyte (TiB)
pebibyte (PiB)
exbibyte (EiB)
x The amount of the previous denomination
present in the data storage size, e.g.,
bits in a byte
1024 mebibytes in a gibibyte
2 Calculate the file lee ssize
ize ofof an im
mage
image e fi
file
le and
nd x Answers
A sw
An wer must
ers muustt bee gi given
givven in the
he uunits
in th niits sspecified
pe
ecified
a sound
so
oun
und file,
file
fi lee, using
usin
inng information
innffo
ormationn given
give
ve
en inn the
he question
que
uest
s ion
ioon
x Information given may include:
Image
Im
mag
agee re
resosolu
so luuttiion
resolution o a n ccolor
nd
and olor
ol orr d epth
ep
depth th
Sound sample rate, resolution and
length of track
3 Understand the purpose of a nd need for x
and Compression exists to reduce the size of
data compression the file
x The impact of this is, e.g.,
Less bandwidth required
Less storage space required
Shorter transmission time
4 Understand how files are compressed using x Lossless compression reduces the file size
lossy and lossless compression methods without permanent loss of data, e.g. run
length encoding (RLE)
x Lossy compression reduces the file size by
permanently removing data, e.g., reducing
resolution or color depth, reducing sample
rate or resolution
+92-335-8467840
[email protected]
CS WITH
SK
Denary
D
Deenary
yNNumber
um
mbe
b r SSystem
ystem
Denary
Deenary NNumber
umberr SSystem
um uses
ystem use es digits from 0 – 9 and their combinations, also known as Base
10
1 0 number
num b r system.
umbe e . It countss in
syysttem in multiple
mul ple of
ultititipl
ple
pl o 10’s
10’’s such
c as
such as 10,
10, 100,
0 1000
100, 100
00 and so oon.
and n.
104 1 3
10 102 101 100
10000 1000
10
000 100 10 1
3 5 7 4 2
1 ൈ 27 + 0 ൈ 26 + 1 ൈ 25 + 1 ൈ 24 + 0 ൈ 23 + 1 ൈ 22 + 1 ൈ 21 + 1 ൈ 20
1 ൈ 128 + 0 ൈ 64 + 1 ൈ 32 + 1 ൈ 16 + 0 ൈ 8 + 1 ൈ 4 + 1 ൈ 2 + 1 ൈ 1
128 + 0 + 32 + 16 + 0 + 4 + 2 + 1 = 183
+92-335-8467840
[email protected]
CS WITH
SK
3$*(
(10110111) 2 ื (183) 10
Denary to Binary Conversion
There are two methods to convert Denary Number to Binary Number.
Method 1
In this method, subtract the largest possible power of 2 and keep doing this until the value
0 is reached. This will give us the following 8-bit binary number:
(152) 10 ื (?) 2
Method 2
Inn this
thi
his method
method
oddw e successive
we vve
ely divide
successively divvid
idee the
the number
nuumbe
ber by
y22,, un
uuntil
ntitilil th
he rremainder
the ema
main
innde
der iss 0
der 0.. Re
RRead
ead
d the
remama
main
a nde
ders
remainders rs ffrom
rom
ro
om top to bot ttom.
bottom.
FFor
Fo Example:
or Ex
xam 173) 10 ื ((?)
le:: ((173)
ampl
ple:
pl 17 ?) 2
2 173 1
2 86 0
2 43 1
2 21 1
2 10 0
2 5 1
2 2 0
1
(173) 10 ื (10101101) 2
Hexadecimal System
Hexadecimal Number System is based on 16 different digits (0 – 9, A – F), also known as
Base 16. A to F are used to represent (hex) digits i.e. A = 10; B = 11, C = 12; D = 13;
E = 14; F = 15.
164 163 162 161 160
65536 4096 255 16 1
3 2 A C 5
+92-335-8467840
[email protected]
CS WITH
SK
As we know, 16 = 24 this means 1 hex digit is equal to 4 binary digits.
Binary Hexadecimal Denary
0000 0 0
0001 1 1
0010 2 2
0011 3 3
0100 4 4
0101 5 5
0110 6 6
0111 7 7
1000 8 8
1001 9 9
1010 10 A
1011 11 B
1100 12 C
1101 13 D
1110
11110
10 14 E
1111
1
111
111
11 15 F
Binary
B
Binary
y tto
o He
Hexadecimal
ex
xaade
d cimal
To convert
con vertt Binary
onvert Binarry Number to
to Hexadecimal Number we split the bits into groups of 4 bits,
and
a
annnd convert
d co
onvnveert it iinto
ert
er n o Hexadeci
nt Hexadecimal
cima
ci al Number
Numb
Nu e and
mber
mb er and if
if number
numb
nu er of
mber
mb of bits
bits is
bi is not
not a multiple
mul
ultitipl
ulti ple of 4 w
ple
pl we
e can
add
ad
dd 0’ 0’s
0 ’s too tthe
h left.
he
010) 2 ื (?) 16
For Example: (101111100010)
(1011111000
00
0
1 0 1 1 1 1 1 0 0 0 1 0
8 4 2 1 8 4 2 1 8 4 2 1
8 + 2 + 1 = 11 8 + 4 + 2 = 14 2
B E 2
(101111100010) 2 ื (BE2) 16
Hexadecimal to Binary
For converting Hexadecimal to Binary, take each Hexadecimal digit and write down the 4-
bit code corresponding to the digit.
+92-335-8467840
[email protected]
CS WITH
SK
Hexadecimal to Denary
For converting Hexadecimal to Denary multiply it with the respective power of 16.
(8BE) 16 ื (2238) 10
Denary to Hexadecimal
To convert Denary Numberer to Hexadecimal Number successive division by 16 until 0 is
er
reached. Remainders from b ottom to top to get the Hexadecimal Number
bottom
2) 100 ื ((?)
For Example: (2322)
(2322 ?) 16
16 2334
23344 14 = E
16 145
14
145 1
9
((2322)
(232
3 10 ื ((91E)
22)) 10 91EE) 16
91
Uses
Us
ses o
off H
Hexadecimal
exadecimal SSystem
ystem
Hexadecimal System is eas
easier
sier to use as 1 hex digit = 4 binary digits.
Address
Internet Protocol (IP) Addre
ess
Each device connected to a network is given an unique address known as the Internet
Protocol (IP) Address. An IPv4 address is a 32-bit number written in denary or hexadecimal
form: e.g. 109.108.158.1 (or 77.76.9e.01 in hex). IPv4 has updated by the adoption of
IPv6. An IPv6 address is a 128-bit number broken down into 16-bit chunks, represented by
a hexadecimal number. For example: FDEC:BA98:7654:3210:ADFC:BDFF:2990:FFFF
Error Codes
Hex is often used in error messages on your computer. The hex number refers to the memory
location (In computing, this is an address in the primary memory where data values are
stored) of the error. This helps programmers to find and then fix problems.
Media Access Control (MAC) Address
All network adapters and network devices have a Media Access Control (MAC) address.
This is also known as the 'physical address' and is a unique address determined during the
+92-335-8467840
[email protected]
CS WITH
SK
manufacture of each device. This address is given as a set of 6 pairs of hexadecimal
numbers. An example of a MAC address would be: A0-1D-48-FE-5E-F5. You can determine
the physical address of the network adapters in a computer running the Windows operating
system by typing the following command in to a command prompt: ipconfig/all.
Hyper Text Markup Language (HTML) Color Code
HTML is a markup language that is used for processing, definition and presentation of text
like size of the text, color, bold, italic etc. It uses <tags>.
HTML is often used to represent colors of text on the computer screen. All colors can be
made up of different combinations of the three primary colors (red, green and blue). The
different intensity of each color (red, green and blue) is determined by its hexadecimal
value. This means different hexadecimal values represent different colors using the format
#RRGGBB. # symbol represents that the number written in hex form. This system uses two
hex digits to represent a single color e.g. #FA6200.
There are a possible 256 vvalues
alues for red, 256 values for green and 256 values for blue
256
giving a total of 256 x 25
56 x 256 (i.e. 16 777 216) possible colors.
Addition of Bin
Binary
nary D
Digits
ig
gits
Two
Tw
wo Bi
Bit Ad
Bit A
Addition
dditi
dition
on
n
1st Bit
Bt
Bi 2ndd Bit Bit Addition Sum Carry
0 0 0+0 0 0
0 1 0+1 1 0
1 0 1+0 1 0
1 1 1+1 0 1
+92-335-8467840
[email protected]
CS WITH
SK
Example: Add (11001110) 2 + (00100011) 2
1st no 1 1 0 0 1 1 1 0
2nd no 0 0 1 0 0 0 1 1
Sum 1 1 1 0 1 1 0 1
Carry 0 0 0 0 0 0 1 0
Overflow
This type of addition generates an extra bit (9th bit) which shows that sum has exceeded its
value and is also known as Overflow Error and also represents that this number is too large
to be stored in computer using 8 bits.
Example: Add 111 + 223 (01101111) 2 + (11011111) 2
1st no 0 1 1 0 1 1 1 1
2nd no 1 1 0 1 1 1 1 1
Sum 1 0 1 0 0 1 1 1 0
Carry 1 1 1 1 1 1 1 1
Logical
Log
giccal B
Binary
inary
y SShifts
hifts
Comp
Computers
C put
uterrs ca
cann ccarry
arry out a llogical
ogical shift on a sequence of binary numbers. The logical shift
meeans
means ns moving
movivinnng
vi g the
the binary number
number to the left or to the right. Each shift left is equivalent to
nu
mu
m ultltip
ltip plyyinng th
multiplying thee bi
b nary numbe
binary ber by 2 a
be
number nd eeach
and acch sh
a shif
ift
if
f ri
shift righ
ghtt iss eequivalent
gh
right quiv
quival
iv a ent
alennt to divid
iv idin
id
din
ing
dividing g th
he bi
the bin
nary
binary
numb
number
mber
mb er by
by 2.2. If
If any place is
is empty fill it with 0. But we can shift only to certain extent after
which it will contain 0’s onlyy and that would result in the generation of error message.
Example: (00011111) 2 = ((31)
31) 10
Most Significant Bit is the lef
left-most
ft-most bit.
128 64 32 16 8 4 2 1
0 0 0 1 1 1 1 1
(00111110) 2 = (62) 10 ฺ 31 ൈ 21
+92-335-8467840
[email protected]
CS WITH
SK
(01111100) 2 = (124) 10 ฺ 31 ൈ 22
(11111000) 2 = (248) 10 ฺ 31 ൈ 23
(11110000) 2 = (240) 10 ് 31 ൈ 24
The left-most 1-bit has lost which means it has exceeded its limit which results in error.
Two’s Complement
For representing negative
neg
egat
eg attiv
atiive numbers
nnuu we take the most significant bit negative
Example:
Exam
mpl e: (11000110)
plle:
e: (110
(1
(110
000
001
110) 2
11
-12
-128
128
12 8 64 32 16 8 4 2 1
1 1 0 0 0 1 1 0
-128
-12
28 + 64
4 + 4 + 2 = (-58
(-58)
8)2
(-126)10
+92-335-8467840
[email protected]
CS WITH
SK
3$*(
Unicode
Unicode can represent all languages of the world, thus supporting many operating systems,
search engines and internet browsers used globally. There is overlap with standard ASCII
+92-335-8467840
[email protected]
CS WITH
SK
code, since the first 128 (English) characters are the same, but Unicode can support several
thousand different characters in total. It will support up to four bytes per character.
The Unicode consortium was set up in 1991. Version 1.0 was published with five goals; these
were to:
 Create a universal standard that covered all languages and all writing systems
 Produce a more efficient coding system than ASCII
 Adopt uniform encoding where each character is encoded as 16-bit or 32-bit code
 Create unambiguous encoding where each 16-bit and 32-bit value always represents
the same character
 Reserve part of the code for private use to enable a user to assign codes for their own
characters and symbols (useful for Chinese and Japanese character sets, for example).
Representation of Sound
Soundwaves are vibrations in the air. The human ear senses these vibrations and interprets
them as sound. Each sound wave has a frequency, wavelength and amplitude. The amplitude
specifies the loudness of the sound.
+92-335-8467840
[email protected]
CS WITH
SK
Sound waves vary continuously. This means that sound is analogue. Computers cannot work
with analogue data, so sound waves need to be sampled in order to be stored in a
computer. Sampling means measuring the amplitude of the sound wave. This is done using
an analogue to digital converter (ADC).
To convert the analogue data to digital, the sound waves are sampled at regular time
intervals. The amplitude of the sound cannot be measured precisely, so approximate values
are stored.
Sampling Resolutio
Resolution: Number
on: N mber of bit per sample. It is also known as bit depth.
um
Sampling
Samp
pling Rate
ng R atte
Itt iiss th
the number
he nu
umber
mb ssamples
berr of sound saamples taken per second. Measured in Hertz (Hz). 1 Hz means
onee sample
sa
amplle per
mple per second.
sec
e ond.
Higher
Highher
Hi er the
he sampling
the samp ing rate, greater
ampl
pl ter the
grreatte
g ter the file
le size.
fille
fi siz
i e.
Pros
1. Larger dynamic range
2. Better sound quality
3. Less sound distortion
Cons
1. Produces larger file size
2. Takes longer to transmit/download music files
3. Requires greater processing power
CDs have a 16-bit sampling resolution and a 44.1kHz sample rate - that is 44100 samples
every second. This gives high-quality sound reproduction.
+92-335-8467840
[email protected]
CS WITH
SK
Each Pixel can be represented as Binary Number, and so bitmap image is stored in a
computer as a series of binary numbers, so that:
 A black and white image only requires 1 bit per pixel – this mean that each pixel can
be of one of two colors, representing 1 or 0.
 If each pixel is represented by 2 bits, then each pixel can be of one of four colors (22
= 4) representing the FOUR combinations of 0 & 1 i.e. 00, 01, 10, 11.
 If each pixel is represe
ent
n ed by 3 bits, then each pixel can be of one of four colors (23
represented
= 8) representing the EI
EEIGHT
IGHT combinations of 0 & 1 i.e. 000, 001, 010, 011, 100, 101,
110, 111.
Color Depth
Each
Ea ch ccolor
ach olo
ol orr iiss re
represented
epr
pres
essented by number
by nummbe bits.
b r off b Ann 8-bit
itis. A bit color
8-b depth
color dep
pth means
th m eans tthat
ans hatt ea pixel
each piixxel can
bee one
b nee ooff 256
25 56 ccolors (because
olors (bec cause 2 = 256). Modern computers have
ca 8 have a 24-bit color depth,
whic
icch means
which meeanns overoverr 16 million
millioon different colors can be represented.
IImage
Im
Imag
magge Re
R e olu
esoluti
tiion refers too thee nnumber
Resolution umbe
um b r off pixels
be pix
ixel
els
ls that
thhatt m ake
ak
ke up a
make ann im
iimage;
age;
age; ffor
or eexample,
xamp
xa mple
mplee, an
ag
a
imagge co
image ccontains
ont
ntains 4096 × 30 072 pixels (12,582,912 pixels in total).
3072
Drawback of using high resolution images is the increase in file size. As the number of pixels
used to represent the image is increased, the size of the file will also increase. It impacts on
the time to download an image from the internet or the time to transfer images from device
to device. A certain amount of reduction in resolution of an image is possible before the loss
of quality becomes noticeable.
+92-335-8467840
[email protected]
CS WITH
SK
1.3 Data Storage & Compression
Measurement of Data Storage
Bit (Binary Digit): Basic Unit of all computing memory storage terms and is either 1 or 0.
Byte: Smallest memory unit (1 byte = 8 bits).
Name of Memory Size Equivalent Denary Values
Kilobyte (KB) 103 Bytes
Megabyte (MB) 106 Bytes
Gigabyte (GB) 109 Bytes
Terabyte (TB) 1012 Bytes
Petabyte (PB) 1015 Bytes
Exabyte (EB) 1018 Bytes
The above system of numbering now only refers to some storage devices but is technically
inaccurate. It is based on the
he SI (base 10) system of units. 1 TB hard disk drive would allow
he
the storage of 1 ൈ 1012 byt
bytes
yttes
y t according to this system.
measured
Memory size is measu suureed inn terms of powers of 2, another system has been adopted by the
al Electrotechnical
IEC (International Ele
lect
c rotech
ct al Commission)
chnica
ch ca C mm
Co mis onn) that
i sion thhatt is
is based
b seed on the
ba e binary
the inarry system.
bin
inar syst
stem..
st
Name
Na
ame
me ofof Memory
Me
Me Size
Sizze Number
Nu
umb
mber
mbeer ofof Bytes
Byte
Bytees Equivalent
Equi
Eq uiiva
vale
lent
lentt D
Denary
enarry V
enar
en Value
alue
Kilobyte
Kilo
Kilooby
byte (KiB) 210 Bytes 1024 Bytes
Megabyte
Mega
Me g by
ga yte
t (MiB) 210 Bytes 1048576 Bytes
Gigabyte
Giga
Gi gaaby
b te (GiB) 2300 BBytes
ytes
ytes 1073741824
1073
10 073
7374
7418
74 1824
18 24 BBytes
ytes
ytess
TTerabyte
Te
era
rabyte (TiB) 240 Bytes 1099511627776 Bytes
Petabyte (PiB) 250 Bytes 1125899906842624 Bytes
Exabyte (EiB) 260 Bytes 1152921504606846976 Bytes
+92-335-8467840
[email protected]
CS WITH
SK
Example
A photograph is 1024 ൈ 1080 pixels and uses a color depth of 32 bits. How many
photographs of this size would fit onto a memory stick of 64 GB.
Multiply number of pixels in vertical and horizontal directions to find total number of pixels
= [1024 ൈ 1080] = 1 150 920 Pixels.
Multiply number of pixels by color depth then divide by 8 to give the number of bytes = 1
105 920 ൈ 32 = 35 389 440/8 bytes = 4 423 680 bytes.
64 GB = 64 ൈ 1024 ൈ 1024 = 68 719 476 736 bytes.
Divide the memory stick size by the file size = 68 719 476 736/4 = 423 680 = 15 534
photos.
Data Compression
Sound and Image files can be b sometimes very large. It is necessary to reduce (or compress)
the size of a file for the following
folllowing reasons:
 To save storage sp spa
pac
ace oonn devices such as the hard disk drive/solid state drive
space
 To reduce th the
he ttime
imee taken
e too stream
en st a music
u icc orr video
mus vi file
fiile » to
to reduce the time taken to
uplo
up load
ad,, do
upload, d ownwnllo
downloadload or trransfer
transfererr a fille a
file croossss a nnetwork
across ettwoorkk
 The
The download/upload
down
ownlo
wnnlo
l ada /upload process esss uses
procces es up
up network
netw
ne orkk bandwidth
wor band
ba dwiidt dth - this
thhis is the
is th maximum
he ma
maxi imum rate
m ra
rat
te of
transf
ansf
sfer
fer ooff data
transfer da acrosss a network, measured in bits per second. This occurs whenever a
da
file
fi e is downloaded,
is do
d ownlooaded, forr eexample,
dow xam
ampl
am
mpl e, ffrom
ple, ro
om a se server.
servrver
rverr. Compressed
Comp
Co mpre
mp reesse files
s ed filles contain
con
ontaainn fewer
ta fewer bits
ewer biti s of
data
data
da ta tthan
h n un
ha uuncompressed
ncompressed d files and therefore use less bandwidth, which results in a faster
data
da
daataa ttransfer
ta ransfer rate.
 Reduced file size also reducesreduces costs. For example, when using cloud storage, the cost is
based on the size of the e files stored. Internet Service Provider (ISP) may charge a user
based on the amount off data downloaded.
+92-335-8467840
[email protected]
CS WITH
SK
Lossy Files are smaller in comparison to Lossless Files and benefits storage and data transfer
rate.
Some of Lossy Files Compression algorithms are: MP3, MP4, JPEG
MP3
When Internet file-sharing boomed into popularity with Napster and the iPod, the MP3
cornered the market for one reason: it had a small footprint. Without broadband
connections, it was impractical at the time to share file sizes larger than the MP3 standard
2 – 3 Megabytes. And that preference has stuck for some time now even though MP3 does
not have nearly the same amount of quality as WAV or AIFF files. Despite this growing base
of people using higher quality formats, there are still those who prefer the So, if you have
a slower internet connection or limited hard drive space, MP3 could be your file format of
choice. If you’re worried about quality loss, don’t fret too much about it. While, yes, there is
a noticeable drop off in sound quality, MP3 files fall square under the “good enough”
umbrella.
MP4
This format allowss tthe storage
he stora
he rra
a
age of multimedia files rather than just sound - music, videos,
photos and ani animation
nim
ni matition
onn can a allll b
be stored
e st
stooredd iinn th
the MP4
he MP
M 4 foformat.
form
r at
at.t. As w with MP3,
itith MP
M this
3,, thi
3 i a llossy
is is o syy file
os
compression
co
om
mp pre
pre
r ssssioon foformat,
mat, but it sstill
orm till rretains
etai
et
tai
ai s a
ains ann acc
acceptable
c ep
ccepta
ab quality
blle qu
q uallitityy of ssound
qual ound
ou daand d vvideo.
nd ideo
id eoo. Mo
Movies,
example,
for ex ample,, ccould
xampl ould be streamed
stre
eamed over the internet using the MP4 format without losing any
real
rea
all d
a discernible
issce
erni
rnniib
ble qquality.
u lity.
ua
JJPEG
PEG
EG
G
When a camera takes a ph photograph,
hotograph, it produces a raw bitmap file which can be very large
in size. These files are temporary
tempo
po
p orary in nature. JPEG is a lossy file compression algorithm used
for bitmap images. As withh MP3, once the image is subjected to the JPEG compression
formed
algorithm, a new file is forme
m d and the original file can no longer be constructed.
 Human eyes don't detect differences in color shades quite as well as they detect
differences in image brightness (the eye is less sensitive to color variations than it is to
variations in brightness)
 Separating pixel color from brightness, images can be split into 8x8 pixel blocks, for
example, which then allows certain 'information' to be discarded from the image without
causing any real noticeable deterioration in quality.
+92-335-8467840
[email protected]
CS WITH
SK
Run Length Encoding (RLE)
Run Length Encoding (RLE) can be used for lossless compression of a number of different file
formats:
RLE on Text Data
Consider the following text string: 'aaabbbbccccddddd'. Assuming each character requires
lbyte then this string needs 16 bytes. If we assume ASCII code is being used, then the string
can be coded as follows:
a a a b b b b c c c c d d d d d
03 97 04 98 04 99 05 100
This has 15 values and would, therefore, require 15 bytes of storage. This is a reduction in
file size of about 53% when compared to the original string.
+92-335-8467840
[email protected]
CS WITH
SK
Example 1: Black & White Images
2R, 2G,3B
3B, 4R
7G
4B,3R
4G,3B
4R, 3G
2B,3G,2R
RRLE
Thee RLLE co de hhas
code as 92 values,
value
es, which means the compressed file will be 92 bytes in size. This
gives
vees a file
give file reduction of about
fil
fi bout 52%. It should be noted that the file reductions in reality will
ab
not be as large as this due ttoo other data which needs to be stored with the compressed file
(e.g. a file header).
+92-335-8467840