01 Information Representation & Multimedia
01 Information Representation & Multimedia
and multimedia
1.1 Data representation
In this chapter, you will learn about
★ binary magnitudes, binary prefixes and decimal prefixes
★ binary, denary and hexadecimal number systems
★ how to carry out binary addition and subtraction
★ the use of hexadecimal and binary coded decimal (BCD) number
systems
★ the representation of character sets (such as ASCII and Unicode)
★ how data for a bit-mapped image is encoded
★ how to estimate the file size for a bit-map image
★ image resolution and colour depth
★ encoding of vector graphics
★ the representation of sound in a computer
★ the effects of changing sampling rate and resolution on sound quality
★ the need for file compression methods (such as lossy and lossless
formats)
★ how to compress common file formats (such as text files, bit-map
images, vector graphics, sound files and video files).
1.1
d) 0 1 1 1 0 1 0 0 128 64 32 16 8 4 2 1
e) 1 1 1 1 1 1 1 1
Data representation
0 1 1 0 1 0 1 1
f) 0 0 0 0 1 1 1 1
g) 1 0 0 0 1 1 1 1 Method 2
h) 0 0 1 1 0 0 1 1 This method involves successive division by 2; the remainders are then written
i) 0 1 1 1 0 0 0 0 from bottom to top to give the binary value.
j) 1 1 1 0 1 1 1 0 2 107
2 53 remainder: 1
ACTIVITY 1B 2 26 remainder: 1
Write the remainder from
2 13 remainder: 0
Convert these bottom to top to get the
2 6 remainder: 1
denary numbers into binary number:
2 3 remainder: 0 01101011
binary (using either
method). 2 1 remainder: 1
a) 4 1 2 0 remainder: 1
b) 6 7 0 remainder: 0
c) 8 6
Binary addition and subtraction
d) 1 0 0
e) 1 1 1
Up until now we have assumed all binary numbers have positive values. There are a
number of methods to represent both positive and negative numbers. We will consider:
f) 1 2 7
g) 1 4 4 » one’s complement
» two’s complement.
h) 1 8 9
i) 2 0 0 In one’s complement, each digit in the binary number is inverted (in other
j) 2 5 5 words, 0 becomes 1 and 1 becomes 0). For example, 0 1 0 1 1 0 1 0 (denary
value 90) becomes 1 0 1 0 0 1 0 1 (denary value −90).
In two’s complement, each digit in the binary number is inverted and a ‘1’ is
added to the right-most bit. For example, 0 1 0 1 1 0 1 0 (denary value 90)
becomes:
1 0 1 0 0 1 0 1
+ 1
= 1 0 1 0 0 1 1 0 (since 1 + 1 = 0, a carry of 1) = denary value −90
Throughout the remainder of this chapter, we will use the two’s complement
method to avoid confusion. Also, two’s complement makes binary addition
and subtraction more straightforward. The reader is left to investigate one’s
complement and the sign and magnitude method in binary arithmetic.
Now that we are introducing negative numbers, we need a way to represent
these in binary. The two’s complement uses these weightings for an 8-bit
number representation:
−128 64 32 16 8 4 2 1
3
The easiest way to convert a number into its negative equivalent is to use two’s
complement. For example, 104 in binary is 0 1 1 0 1 0 0 0.
To find the binary value for −104 using two’s complement:
invert the digits: 1 0 0 1 0 1 1 1 (+104 in denary)
add 1: 1
which gives: 1 0 0 1 1 0 0 0 = −104)
ACTIVITY 1C
Convert these denary numbers into 8-bit binary numbers using two’s
complement where necessary. Use these binary column weightings:
−128 64 32 16 8 4 2 1
a) +114
b) +61
c) +96
d) −14
e) −116
Binary addition
Consider Examples 1.1 and 1.2.
Solution
−128 64 32 16 8 4 2 1
0 0 1 0 0 1 0 1
+
0 0 1 1 1 0 1 0
=
0 1 0 1 1 1 1 1
Solution
1
−128 64 32 16 8 4 2 1
0 1 0 1 0 0 1 0
+
0 1 0 0 0 1 0 1
1.1
=
Data representation
1 0 0 1 0 1 1 1
Binary subtraction
To carry out subtraction in binary, we convert the number being subtracted into
its negative equivalent using two’s complement, and then add the two numbers.
Solution
1 Convert the two numbers into binary:
95 = 0 1 0 1 1 1 1 1
68 = 0 1 0 0 0 1 0 0
2 Find the two’s complement of 68:
−128 64 32 16 8 4 2 1
0 1 0 1 1 1 1 1
+
1 0 1 1 1 1 0 0
=
1 0 0 0 1 1 0 1 1
The additional ninth bit is simply ignored leaving the binary number
0 0 0 1 1 0 1 1 (denary equivalent of 27, which is the correct result of the
subtraction).
−128 64 32 16 8 4 2 1
0 0 1 1 0 0 0 1
+
1 0 1 1 0 0 0 0
=
1 1 1 0 0 0 0 1
This gives us 1 1 1 0 0 0 0 1, which is −31 in denary; the correct answer.
ACTIVITY 1D
Carry out these binary additions and subtractions using these 8-bit column
weightings:
−128 64 32 16 8 4 2 1
a) 00111001+00101001
b) 01001011+00100011
c) 01011000+00101000
d) 01110011+00111110
e) 00001111+00011100
f) 01100011−00110000
g) 01111111−01011010
h) 00110100−01000100
i) 00000011−01100100
j) 11011111−11000011
1.1
The system of numbering shown in Table 1.1 only refers to some storage
devices, but is technically inaccurate. It is based on the SI (base 10) system
Data representation
of units where 1 kilo is equal to 1000. A 1 TB hard disk drive would allow the
storage of 1 × 1012 bytes according to this system. However, since memory size
is actually measured in terms of powers of 2, another system has been proposed
by the International Electrotechnical Commission (IEC); it is based on the
binary system. See Table 1.2.
Name of memory size Number of bytes Equivalent denary value (bytes)
1 kibibyte (1 KiB) 210 1 024
1 mebibyte (1 MiB) 220 1 048 576
1 gibibyte (1 GiB) 230 1 073 741 824
1 tebibyte (1 TiB) 240 1 099 511 627 776
1 pebibyte (1 PiB) 250 1 125 899 906 842 624
▲ Table 1.2 IEC memory size system
1 0000
0001
0
1
0
1
0010 2 2
0011 3 3
0100 4 4
0101 5 5
0110 6 6
1 Information representation and multimedia
0111 7 7
1000 8 8
1001 9 9
1010 A 10
1011 B 11
1100 C 12
1101 D 13
1110 E 14
1111 F 15
▲ Table 1.3 The link between binary, hexadecimal and denary
Solution
First split it into groups of 4 bits:
1011 1110 0001
Then find the equivalent hexadecimal digits:
B E 1
Solution
First split it into groups of 4 bits:
10 0001 1111 1101
The left group only contains 2 bits, so add in two 0s to the left:
0010 0001 1111 1101
Now find the equivalent hexadecimal digits:
2 1 F D
1.1
Data representation
Converting from hexadecimal to binary is also straightforward. Using the data
from Table 1.3, simply take each hexadecimal digit and write down the 4 bit
code which corresponds to the digit.
Solution
Using Table 1.3, find the 4-bit code for each digit:
0 1 0 0 0 1 0 1 1 0 1 0
Put the groups together to form the binary number:
010001011010
Solution
Using Table 1.3:
1 0 1 1 1 1 1 1 0 0 0 0 1 0 0 0
Then put all the digits together:
1011111100001000
d) A 0 0
A program developer can look at each of the hexadecimal codes (as shown in
e) 4 0 E
Table 1.4) and determine where the error lies. The value on the far left shows
f) B A 6 the memory location, so it is possible to find out exactly where in memory
g) 9 C C the fault occurs. Using hexadecimal is more manageable than binary. It is a
h) 4 0 A A powerful fault-tracing tool, but requires considerable knowledge of computer
i) D A 4 7 architecture to be able to interpret the results.
j) 1 A B 0
1.1.4 Binary-coded decimal (BCD) system
The binary-coded decimal (BCD) system uses a 4-bit code to represent each
denary digit:
0 0 0 0 = 0 0101=5
0 0 0 1 = 1 0110=6
0 0 1 0 = 2 0111=7
0 0 1 1 = 3 1000=8
0 1 0 0 = 4 1001=9
Therefore, the denary number 3 1 6 5 would be 0 0 1 1 0 0 0 1 0 1 1 0 0 1 0 1
in BCD format.
The 4-bit code can be stored in the computer either as half a byte or two 4-bit
codes stored together to form one byte. For example, using 3 1 6 5 again …
Method 1: four single bytes
0 0 0 0 0 0 1 1 3
0 0 0 0 0 0 0 1 1
0 0 0 0 0 1 1 0 6
0 0 0 0 0 1 0 1 5
0 0 1 1 0 0 0 1 3 1
0 1 1 0 0 1 0 1 6 5
ACTIVITY 1G
1 Convert these denary numbers into BCD format.
a) 2 7 1 b) 5 0 0 6 c) 7 9 9 0
2 Convert these BCD numbers into denary numbers.
a) 1 0 0 1 0 0 1 1 0 1 1 1
b) 0 1 1 1 0 1 1 1 0 1 1 0 0 0 1 0
10
Each denary digit will have a BCD equivalent value which makes it easy to
convert from computer output to denary display.
1.1
As you will learn in Chapter 13, it is nearly impossible to represent decimal
Data representation
values exactly in computer memories which use the binary number system.
Normally this doesn’t cause a major issue since the differences can be dealt
with. However, when it comes to accounting and representing monetary
values in computers, exact values need to be stored to prevent significant
errors from accumulating. Monetary values use a fixed-point notation, for
example $1.31, so one solution is to represent each denary digit as a BCD
value.
Consider adding $0.37 and $0.94 together using fixed-point decimals.
$0.37 0 0 0 0 0 0 0 0 . 0 0 1 1 0 1 1 1
+ +
$0.94 0 0 0 0 0 0 0 0 . 1 0 0 1 0 1 0 0 Expected result = $1.31
0 1 1 1
+
0 1 0 0
=
1 0 1 1 This produces 1 0 1 1 which
isn’t a denary digit; this
will flag an error and the
computer needs to add
This now 1 0 1 1 0 1 1 0.
produces a fifth +
bit which is
0 1 1 0
carried to the
next decimal =
digit position. 1 0 0 0 1
11
1
remembering the carry bit from the addition above:
0 0 1 1
+
1 0 0 1
1 Information representation and multimedia
+
1
=
1 1 0 1
This produces 1 1 0 1 which isn’t a denary digit; this will flag an error and the
computer again needs to add 0 1 1 0.
1 1 0 1
This again produces +
a fifth bit which is 0 1 1 0
carried to the next =
decimal digit position. 1 0 0 1 1
ACTIVITY 1H
Adding 1 to 0 0 0 0 0 0 0 0 produces:
Carry out these BCD
0 0 0 0 0 0 0 1
additions.
a) 0.45 + 0.21 Final answer:
b) 0.66 + 0.51
c) 0.88 + 0.75 0 0 0 0 0 0 0 1 . 0 0 1 1 0 0 0 1
12
1.1
39 27 ‘ 71 47 G 103 67 g
Data representation
40 28 ( 72 48 H 104 68 h
41 29 ) 73 49 I 105 69 i
42 2A * 74 4A J 106 6A j
43 2B + 75 4B K 107 6B k
44 2C , 76 4C L 108 6C l
45 2D - 77 4D M 109 6D m
46 2E . 78 4E N 110 6E n
47 2F / 79 4F O 111 6F o
48 30 0 80 50 P 112 70 p
49 31 1 81 51 Q 113 71 q
50 32 2 82 52 R 114 72 r
51 33 3 83 53 S 115 73 s
52 34 4 84 54 T 116 74 t
53 35 5 85 55 U 117 75 u
54 36 6 86 56 V 118 76 v
55 37 7 87 57 W 119 77 w
56 38 8 88 58 X 120 78 x
57 39 9 89 59 Y 121 79 y
58 3A : 90 5A Z 122 7A z
59 3B ; 91 5B [ 123 7B {
60 3C < 92 5C \ 124 7C |
61 3D = 93 5D ] 125 7D }
62 3E > 94 5E ^ 126 7E ~
63 3F ? 95 5F _ 127 7F <DELETE>
▲ Table 1.5 Part of the ASCII code table
Notice the storage of characters with uppercase and lowercase. For example:
a 1 1 0 0 0 0 1 hex 61 (lower case)
A 1 0 0 0 0 0 1 hex 41 (upper case)
y 1 1 1 1 0 0 1 hex 79 (lower case)
Y 1 0 1 1 0 0 1 hex 59 (uppercase)
Notice the sixth bit changes from 1 to 0 when comparing lower and uppercase
characters. This makes the conversion between the two an easy operation. It
is also noticeable that the character sets (such as a to z, 0 to 9, and so on) are
grouped together in sequence, which speeds up usability.
Extended ASCII uses 8-bit codes (128 to 255 in denary or 80 to FF in hex). This
allows for non-English characters and for drawing characters to be included.
13
1
128 80 Ç 154 9A Ü 180 B4 ┤ 206 CE ╬ 232 E8 Φ
129 81 ü 155 9B ḉ 181 B5 ╡ 207 CF ╧ 233 E9 Θ
130 82 é 156 9C £ 182 B6 ╢ 208 D0 ╨ 234 EA Ω
131 83 â 157 9D ¥ 183 B7 ╖ 209 D1 ╤ 235 EB δ
132 84 ä 158 9E ₧ 184 B8 ╕ 210 D2 ╥ 236 EC ∞
133 85 à 159 9F ƒ 185 B9 ╣ 211 D3 ╙ 237 ED ø
134 86 å 160 A0 á 186 BA ║ 212 D4 ╘ 238 EE ε
135 87 ç 161 A1 í 187 BB ╗ 213 D5 ╒ 239 EF ∩
1 Information representation and multimedia
Since ASCII code has a number of disadvantages and is unsuitable for some
purposes, different methods of coding have been developed over the years.
One coding system is called Unicode. Unicode allows characters in a code
form to represent all languages of the world, thus supporting many operating
systems, search engines and internet browsers used globally. There is overlap
with standard ASCII code, since the first 128 (English) characters are the same,
but Unicode can support several thousand different characters in total. As can
be seen in Tables 1.5 and 1.6, ASCII uses one byte to represent a character,
whereas Unicode 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 or 32-bit value always
represents the same character (it is worth pointing out here that the ASCII
code tables are not standardised and versions other than the ones shown in
tables 1.5 and 1.6 exist)
» 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).
A sample of Unicode characters are shown in Table 1.7. As can be seen from
the table, characters used in languages such as Russian, Greek, Romanian and
Croatian can now be represented in a computer).
14
1.2
0210 Ȑ ȑ Ȓ ȓ Ȕ ȕ Ȗ ȗ Ș ș Ț ț Ȝ ȝ Ȟ ȟ
Multimedia
0220 Ƞ ȡ Ȣ ȣ Ȥ ȥ Ȧ ȧ Ȩ ȩ Ȫ ȫ Ȭ ȭ Ȯ ȯ
0230 Ȱ ȱ Ȳ ȳ ȴ ȵ ȶ ȷ ȸ ȹ Ⱥ Ȼ ȼ Ƚ Ⱦ ȿ
0240 ɀ Ɂ ɂ Ƀ Ʉ Ʌ Ɇ ɇ Ɉ ɉ Ɋ ɋ Ɍ ɍ Ɏ ɏ
0250 ɐ ɑ ɒ ɓ ɔ ɕ ɖ ɗ ɘ ǝ ɚ ɛ ɜ ɝ ɞ ɟ
0260 ɠ ɡ ɢ ɣ ɤ ɥ ɦ ɧ ɨ ɩ ɪ ɫ ɬ ɭ ɮ ɯ
0270 ɰ ɱ ɲ ɳ ɴ ɵ ɶ ɷ ɸ ɹ ɺ ɻ ɼ ɽ ɾ ɿ
0280 ʀ ʁ ʂ ʃ ʄ ʅ ʆ ʇ ʈ ʉ ʊ ʋ ʌ ʍ ʎ ʏ
0290 ʐ ʑ ʒ ʓ ʔ ʕ ʖ ʗ ʘ ʙ ʚ ʛ ʜ ʝ ʞ ʟ
02A0 ʠ ʡ ʢ ʣ ʤ ʥ ʦ ʧ ʨ ʩ ʪ ʫ ʬ ʭ ʮ ʯ
02B0 ʰ ʱ ʲ ʳ ʴ ʵ ʶ ʷ ʸ ʹ ʺ ʻ ʼ ʽ ʾ ʿ
1.2 Multimedia
Key terms
Bit-map image – system that uses pixels to make up an resolution is smaller than the image resolution, the
image. whole image cannot be shown on the screen, or the
Pixel – smallest picture element that makes up an image. original image will become lower quality.
Colour depth – number of bits used to represent the Resolution – number of pixels per column and per row
colours in a pixel, e.g. 8 bit colour depth can represent on a monitor or television screen.
28 = 256 colours. Pixel density – number of pixels per square centimetre.
Bit depth – number of bits used to represent the Vector graphics – images that use 2D points to describe
smallest unit in, for example, a sound or image file – lines and curves and their properties that are grouped to
the larger the bit depth, the better the quality of the form geometric shapes.
sound or colour image. Sampling resolution – number of bits used to represent
Image resolution – number of pixels that make up an sound amplitude (also known as bit depth).
image, for example, an image could contain 4096 × 3192 Sampling rate – number of sound samples taken per
pixels (12 738 656 pixels in total). second.
Screen resolution – number of horizontal and vertical Frame rate – number of video frames that make up a
pixels that make up a screen display. If the screen video per second.
Images can be stored in a computer in two common formats: bit-map image and
vector graphic.
15
1
now fit on the screen without any modification to the image. We could simply
zoom in to enlarge it to full screen size; however, the image could now become
pixelated (in other words, the number of pixels per square inch (known as the
pixel density) is smaller, causing deterioration in the image quality).
We will now consider a calculation which shows how pixel density can be
calculated for a given screen. Imagine we are using an Apple iPhone 8 which
has 5.5-inch screen size and screen resolution of 1920 pixels × 1080 pixels:
1 add together the squares of the resolution size ((19202 + 10802) = (3 686 400
1.2
+ 16 640) = 4 852 800)
Multimedia
(
2 find the square root 4852800 = 2202.907 )
3 divide by screen size (2202.907 ÷ 5.5 = 401)
This gives us the pixel density of 401 pixels per square inch (ppi) (which is the
same as the published figure from the manufacturer).
A pixel-generated image can be scaled up or scaled down; it is important
to understand that this can be done when deciding on the resolution. The
resolution can be varied on many cameras before taking, for example, a digital
photograph. When magnifying an image, the number of pixels that makes up
the image remains the same but the area they cover is now increased. This
means some of the sharpness could be lost. This is known as the pixel density
and is key when scaling up photographs. For example, look at Figure 1.3.
A B C D E
▲ Figure 1.3 Five images of the same car wheel
Image A is the original. By the time it has been scaled up to make image E it
has become pixelated (‘fuzzy’). This is because images A and E have different
pixel densities.
The main 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. This impacts on how many images can be stored on, for example,
a hard drive. It also impacts on the time to download an image from the internet or
the time to transfer images from device to device. Bit-map images rely on certain
properties of the human eye and, up to a point, the amount of file compression
used (see Section 1.3 File compression). The eye can tolerate a certain amount of
resolution reduction before the loss of quality becomes significant.
1
contain items such as file type (.bmp or .jpeg), file size, image resolution, bit depth
(usually 1, 8, 16, 24 or 32), any type of data compression employed and so on.
A vector graphic will contain a drawing list (included in a file header) that is
made up of
» the command used for each object that makes up the graphic image
▲ Figure 1.4 Drawing of a » the attributes that define the properties that make up each object (for
robot made up of a number example consider the ellipse of the robot’s mouth – this will need the
of geometric shapes position of the two centres, the radius from centres, the thickness and style
of each line, the line colour and any fill colour used)
» the relative position of each object will also need to be included
» the dimensions of each object are not defined, but the relative positions of
objects to each other in the final graphic need to be defined; this means
that scaling up the vector graphic image will result in no loss of quality.
When printing out vector graphics it is usually necessary to first convert it into
a bit-map image to match the format of most printers.
18
1
diagram’ of a car engine, vector graphics are the best choice.
However, when modifying photographs using photo software, the best method
is to use bit-map images.
1.2
within the medium. The human ear picks up these oscillations (changes in air
pressure) and interprets them as sound. Each sound wave has a frequency and
Multimedia
wavelength; the amplitude specifies the loudness of the sound.
high frequency wave
Pressure
Time
period
Time
period
10
9
Sound amplitude
8
7
6
5
4
3
2
1
0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Time intervals
19
1
the sound was sampled (0 to 20), and the y-axis shows the amplitude of the
sampled sound (the amplitudes above 10 and below 0 are filtered out in this
example).
At time interval 1, the approximate amplitude is 9; at time interval 2, the
approximate amplitude is 4, and so on for all 20 time intervals. Because the
amplitude range in Figure 1.6 is 0 to 10, then 4 binary bits can be used to
represent each amplitude value (for example, 9 would be represented by the
binary value 1001). Increasing the number of possible values used to represent
1 Information representation and multimedia
sound amplitude also increases the accuracy of the sampled sound (for
example, using a range of 0 to 127 gives a much more accurate representation
of the sound sample than using a range of, for example, 0 to 10). This is known
as the sampling resolution (also known as the bit depth).
Sampling rate is the number of sound samples taken per second. The higher
the sampling rate and/or sampling resolution, the greater the file size. For
example, a 16-bit sampling resolution is used when recording CDs to give better
sound quality.
So, how is sampling used to record a sound clip?
» The amplitude of the sound wave is first determined at set time intervals
(the sampling rate).
» This gives an approximate representation of the sound wave.
» The sound wave is then encoded as a series of binary digits.
Using a higher sampling rate or larger resolution will result in a more faithful
representation of the original sound source.
Pros Cons
larger dynamic range produces larger file size
better sound quality takes longer to transmit/download sound files
less sound distortion requires greater processing power
▲ Table 1.9 The pros and cons of using a larger sampling resolution when recording sound
1.2.4 Video
This section considers the use of video and extends beyond the syllabus. While
this is not specifically mentioned in the syllabus, it has been included here
for completeness. Many specialist video cameras exist. However, most digital
cameras, smart phones and tablets are also capable of taking moving images by
‘stitching’ a number of still photos (frames) together. They are often referred to
as DV (digital video) cameras; they store compressed photo frames at a speed
of 25 MB per second – this is known as motion JPEG.
20
1
the image and turns it into an electronic signal using light-sensitive sensors.
In the case of the DV cameras, these signals are automatically converted into a
compressed digital file format.
When recording video, the frame rate refers to the number of frames recorded
per second.
1.3
Key terms
File compression
Lossless file compression – file compression method Audio compression – method used to reduce the size of
where the original file can be restored following a sound file using perceptual music shaping.
decompression. Perceptual music shaping – method where sounds
Lossy file compression – file compression method outside the normal range of hearing of humans, for
where parts of the original file cannot be recovered example, are eliminated from the music file during
during decompression, so some of the original detail compression.
is lost. Bit rate – number of bits per second that can be
JPEG – Joint Photographic Expert Group – a form of transmitted over a network. It is a measure of the data
lossy file compression based on the inability of the eye transfer rate over a digital telecoms network.
to spot certain colour changes and hues. Run length encoding (RLE) – a lossless file
MP3/MP4 files – file compression method used for compression technique used to reduce text and photo
music and multimedia files. files in particular.
It is often necessary to reduce the file size of a file to either save storage
space or to reduce the time taken to stream or transmit data from one device
to another (see Chapter 2). The two most common forms of file compression are
lossless file compression and lossy file compression.
Lossless file compression
With this technique, all the data from the original file can be reconstructed
when the file is uncompressed again. This is particularly important for files
where loss of any data would be disastrous (such as a spreadsheet file of
important results).
Lossy file compression
With this technique, the file compression algorithm eliminates unnecessary
data (as with MP3 and JPEG formats, for example).
Lossless file compression is designed to lose none of the original detail from
the file (such as Run-Length Encoding (RLE) which is covered later in this
chapter). Lossy file compression usually results in some loss of detail when
compared to the original; it is usually impossible to reconstruct the original
file. The algorithms used in the lossy technique have to decide which parts of
the file are important (and need to be kept) and which parts can be discarded.
We will now consider file compression techniques applied to multimedia files.
1
can be downloaded or streamed from the internet in a compressed format, or
CD files can be converted to MP3 format. While streamed or MP3 music quality
can never match the ‘full’ version found on a CD, the quality is satisfactory for
most purposes.
But how can the original music file be reduced by 90% while still retaining
most of the music quality? This is done using file compression algorithms that
use perceptual music shaping.
Perceptual music shaping removes certain sounds. For example
1 Information representation and multimedia
This means that certain parts of the music can be removed without affecting
the quality too much. MP3 files use what is known as a lossy format, since part
of the original file is lost following the compression algorithm. This means that
the original file cannot be put back together again. However, even the quality
of MP3 files can be different, since it depends on the bit rate – this refers
to the number of bits per second used when creating the file. Bit rates are
between 80 and 320 kilobits per second; usually 200 kilobits or higher gives a
sound quality close to a normal CD.
MPEG-4 (MP4) files are slightly different to MP3 files. This format allows the
EXTENSION storage of multimedia files rather than just sound. Music, videos, photos and
ACTIVITY 1D animation can all be stored in the MP4 format. Videos, for example, could
be streamed over the internet using the MP4 format without losing any real
Find out how file discernible quality (see Chapter 2 for notes on video streaming).
compression can
be applied to a Photographic (bit-map) images
photograph without When a photographic file is compressed, both the file size and quality of image
noticeably reducing are reduced. A common file format for images is JPEG, which uses lossy file
its quality. Compare compression. Once the image is subjected to the JPEG compression algorithm,
this to run-length
a new file is formed and the original file can no longer be constructed. A JPEG
encoding (RLE),
described below. will reduce the raw bit-map image by a factor of between 5 and 15, depending
on the quality of the original.
Vector graphics can also undergo some form of file compression. Scalable
vector graphics (.svg) are defined in XML text files which, therefore, allows
them to be compressed.
22
This means we have five characters with ASCII code 97, four characters with
1.3
ASCII code 98, two characters with ASCII code 99, and five characters with
ASCII code 100. Assuming each number in the second row requires 1 byte of
File compression
memory, the RLE code will need 8 bytes. This is half the original file size.
One issue occurs with a string such as ‘cdcdcdcdcd’, where compression is not
very effective. To cope with this we use a flag. A flag preceding data indicates
that what follows are the number of repeating units (for example, 255 05 97
where 255 is the flag and the other two numbers indicate that there are five
items with ASCII code 97). When a flag is not used, the next byte(s) are taken
with their face value and a run of 1 (for example, 01 99 means one character
with ASCII code 99 follows).
Consider this example:
String aaaaaaaa bbbbbbbbbb c d c d c d eeeeeeee
Code 08 97 10 98 01 99 01 100 01 99 01 100 01 99 01 100 08 101
1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 1 In compressed RLE format this becomes:
1 0 1 1 1 1 1 1
9W 6B 2W 1B 7W 1B 7W 5B 3W 1B 7W
1 0 1 1 1 1 1 1 1B 7W 1B 6W
1 0 0 0 0 0 1 1
1 0 1 1 1 1 1 1 Using W = 1 and B = 0 we get:
1 0 1 1 1 1 1 1 91 60 21 10 71 10 71 50 31 10 71 10 71
1 0 1 1 1 1 1 1 10 61
The 8 × 8 grid would need 64 bytes; the compressed RLE format has 30 values,
and therefore needs only 30 bytes to store the image.
23
1 Figure 1.8 shows an object in four colours. Each colour is made up of red, green
and blue (RGB) according to the code on the right.
0 0 0
1 Information representation and multimedia
0 255 0
255 0 0
24
1.3
Describe how the music quality is essentially retained.
3 a) What is meant by run length encoding?
File compression
b) Describe how RLE compresses a file. Give an example in your
description.
4 a) Describe the differences between bit-map images and vector graphics.
b) A software designer needs to incorporate images into her software to
add realism.
Explain what she needs to consider when deciding between using
bit-map images and vector graphics in her software.
End of chapter 1 a) The following bytes represent binary integers using the two’s complement
questions form. State the equivalent denary values.
i) 0 1 0 0 1 1 1 1 [1]
ii) 1 0 0 1 1 0 1 0 [1]
iii)Write the integer −53 in two’s complement form. [1]
iv) Write the maximum possible range of numbers using the two’s
complement form of an 8-bit binary number.
Give your answers in denary. [2]
b) i) Write the denary integer 798 in binary-coded decimal (BCD) format. [1]
ii) Write the denary number that is represented by the following BCD number.
1 0 0 1 0 1 1 1 0 1 1 1 0 1 1 0
[2]
c) Give one use of binary-coded decimal system. [1]
2 A software developer is using a microphone and a sound editing app to
collect and edit sounds for his new game.
When collecting sounds, the software developer can decide on the sampling
resolution he wishes to use.
a) i) State what is meant by sampling resolution.[1]
ii) Describe how sampling resolution will affect how accurate the
stored digitised sound will be. [2]
b) The software developer will include images in his new game.
i) Explain the term image resolution.[1]
ii) The software developer is using 16-colour bit-map images.
State the number of bits required to encode data for one pixel of his
image.[1]
iii)One of the images is 16 384 pixels wide and 512 pixels high.
The developer decides to save it as a 256-colour bit-map image.
Calculate the size of the image file in gibibytes. [3]
➔
25
1
State two items you would expect to see in the header. [2]
v) Give three features you would expect to see in the sound editing app. [3]
3 The editor of a movie is finalising the music score. They will send the final
version of the score to the movie producer by email attachment.
a) Describe how sampling is used to record the music sound clips. [3]
b) The music sound clips need to undergo some form of data compression
before the music editor can send them via email.
1 Information representation and multimedia
4 a) Write the denary numbers 60, 27 and −27 in 8-bit binary two’s
complement form. [3]
b) Show the result of the addition 60 + 27 using 8-bit binary two’s
complement form. Show all of your working. [2]
c) Show the result of the subtraction 60 − 27 using 8-bit binary two’s
complement form. [2]
d) Give the result of the following addition.
01011001
+
01100001
Explain why the expected result is not obtained. [2]
5 a) Carry out 0.52 + 0.83 using binary-coded decimal (BCD). Show all
of your working. [4]
b) i) Define the term hexadecimal.[1]
ii) Give two uses of the hexadecimal system. [2]
iii)Convert the following binary number into hexadecimal. [2]
0111111011110010
6 a) Convert the denary number 95 into binary coded decimal (BCD). [1]
b) Using two’s complement, carry out the binary subtraction:
00100011–01000100
and convert your answer into denary. [3]
c) Convert the denary number 506 into hexadecimal. [1]
26