0% found this document useful (0 votes)
22 views

Information Representation As Level

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Information Representation As Level

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 41

Information Representation and Multimedia

Data Representation
Number System:
• Number systems are methods for expressing numbers in a consistent manner using symbols or
digits.
• Different number systems are used for various applications, particularly in mathematics and
computer science.
• Designers of computer systems adopted the binary (base 2) number system since this allows
only two values, 0 and 1.
• No matter how complex the system, the basic building block in all computers is the binary
number system.
• Since computers contain millions and millions of tiny ‘switches’, which must be in the ON or OFF
position, this lends itself logically to the binary system.
• A switch in the ON position can be represented by 1; a switch in the OFF position can be
Binary number system (base 2)
• Digits Used: 0, 1
• Description: The binary system is fundamental in computing and digital electronics.
• Each digit’s place value is a power of 2.
• The binary system uses 1s and 0s only which gives these corresponding weightings:

• A typical binary number would be: 1 1 1 0 1 1 1 0


Converting from binary to denary and from denary to binary
• It is fairly straightforward to change a binary number into a denary number.
• Each time a 1 appears in a column, the column value is added to the total.
• For example, the binary number above is:
• 128 + 64 + 32 + 8 + 4 + 2 = 238 (denary)
• The 0 values are simply ignored when calculating the total.
• Convert these binary numbers into denary:
• a) 0 0 1 1 0 0 1 1
• b) 0 1 1 1 1 1 1 1
• c) 1 0 0 1 1 0 0 1
• d) 0 1 1 1 0 1 0 0
• e) 1 1 1 1 1 1 1 1
• f) 0 0 0 0 1 1 1 1
• g) 1 0 0 0 1 1 1 1
• h) 0 0 1 1 0 0 1 1
• i) 0 1 1 1 0 0 0 0
• The reverse operation – converting from denary to binary – is slightly more complex.
• There are two basic ways of doing this.
• Consider the conversion of the denary number, 107, into binary …
Method 1:
• This method involves placing 1s in the appropriate position so that the total equates to 107.

Method 2:
• This method involves successive division by 2; the remainders are then written from bottom to
top to give the binary value.
1 Divide the decimal number by 2 and record the quotient and the remainder.
2 Continue dividing the quotient by 2 until the quotient is 0.
3 The binary number is the string of remainders read from bottom to top.
Let's convert 45 to binary:

• Reading the remainders from bottom to top: 45 in decimal is 101101 in binary.


Convert these denary numbers into binary (using either method).
• a) 4 1
• b) 6 7
• c) 8 6
• d) 1 0 0
• e) 1 1 1
• f) 1 2 7
• g) 1 4 4
• h) 1 8 9
• i) 2 0 0
• j) 2 5 5
Binary Addition and Subtraction
• 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:
• one’s complement
• two’s complement
» one’s complement
• In one’s complement, each digit in the binary number is inverted (in other 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).
» two’s complement.
• 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:
• 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
• This means:
• −128 64 32 16 8 4 2 1
• 1 1 0 1 1 0 1 0 (The first example is: −128 + 64 + 16 + 8 + 2 = −38)
• 0 0 1 0 0 1 1 0 (The second example is: 32 + 4 + 2 = 38)
• 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:
• 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
• 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
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.
Carry out these binary additions and subtractions using these 8-bit column
weightings: −128 64 32 16 8 4 2 1

• a) 0 0 1 1 1 0 0 1 + 0 0 1 0 1 0 0 1
• b) 0 1 0 0 1 0 1 1 + 0 0 1 0 0 0 1 1
• c) 0 1 0 1 1 0 0 0 + 0 0 1 0 1 0 0 0
• d) 0 1 1 1 0 0 1 1 + 0 0 1 1 1 1 1 0
• e) 0 0 0 0 1 1 1 1 + 0 0 0 1 1 1 0 0
• f) 0 1 1 0 0 0 1 1 − 0 0 1 1 0 0 0 0
• g) 0 1 1 1 1 1 1 1 − 0 1 0 1 1 0 1 0
• h) 0 0 1 1 0 1 0 0 − 0 1 0 0 0 1 0 0
• i) 0 0 0 0 0 0 1 1 − 0 1 1 0 0 1 0 0
• j) 1 1 0 1 1 1 1 1 − 1 1 0 0 0 0 1 1
Measurement of size in computer memories
• A byte is commonly considered the smallest addressable unit of memory, but it's made up of 8
bits.
• Some computer systems use larger units like 16-bit or 32-bit "words," which are multiples of 8
bits.
• Memory size is measured in multiples of bytes (e.g., kilobytes, megabytes) because a single
byte holds only a small amount of information.
• The traditional system of measuring storage uses the SI (base 10) system, where 1 kilo equals
1,000.
• According to this system, a 1 TB hard disk would store 1 × 10¹² bytes. However, memory sizes are
more accurately measured in powers of 2.
• The International Electrotechnical Commission (IEC) has proposed a binary-based system to
address this discrepancy.

• This system is more accurate.


• Internal memories (such as RAM) should be measured using the IEC system.
Hexadecimal number system

• The hexadecimal system is very closely related to the binary system.


• Hexadecimal (sometimes referred to as simply hex) is a base 16 system with the weightings:

• 1048576 65536 4096 256 16 1

• Because it is a system based on 16 different digits, the numbers 0 to 9 and the letters A to F are
used to represent hexadecimal digits.
• A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15.
• Since 16 = 24, four binary digits are equivalent to each hexadecimal digit.
Converting from binary to hexadecimal and from hexadecimal to binary
• Converting from binary to hexadecimal is a fairly easy process.
• Starting from the right and moving left, split the binary number into groups of 4 bits.
• If the last group has less than 4bits, then simply fill in with 0s from the left.
• Take each group of 4 bits and convert it into the equivalent hexadecimal digit
• Convert these binary numbers into hexadecimal.

• a) 1 1 0 0 0 0 1 1
• b) 1 1 1 1 0 1 1 1
• c) 1 0 0 1 1 1 1 1 1 1
• d) 1 0 0 1 1 1 0 1 1 1 0
• e) 0 0 0 1 1 1 1 0 0 0 0 1
• f) 1 0 0 0 1 0 0 1 1 1 1 0
• g) 0 0 1 0 0 1 1 1 1 1 1 1 0
• h) 0 1 1 1 0 1 0 0 1 1 1 0 0
• i) 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1
• j) 0 0 1 1 0 0 1 1 1 1 0 1 0 1 1 1
• Converting from hexadecimal to binary is also straightforward.
• Using the data from Table, simply take each hexadecimal digit and write down the 4bit code
which corresponds to the digit.
• Use of Hexadecimal System
• Memory dumps
• It is much easier to work with: B 5 A 4 1 A F C than it is to work with: 1 0 1 1 0 1 0 1 1 0 1 0 0 1 0 0 0 0 0 1 1 0 1 0
11111100
• So, hexadecimal is often used when developing new software or when trying to trace errors in programs.
• When the memory contents are output to a printer or monitor, this is known as a memory dump.

• Hexadecimal codes help program developers identify the exact memory location of errors, making it easier to
trace faults.
• While hexadecimal is more manageable than binary for fault-tracing, interpreting the results requires a deep
understanding of computer architecture
BCD (Binary Coded Decimal)
• The binary-coded decimal (BCD) system uses a 4-bit code to represent each denary digit:
• 0000=0 0101=5
• 0001=1 0110=6
• 0010=2 0111=7
• 0011=3 1000=8
• 0100=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 …
• Convert these denary numbers into BCD format. (2 7 1, 5 0 0 6, 7 9 9 0)
• 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
• Uses of BCD:
• The most obvious use of BCD is in the representation of digits on a calculator or clock display.
• BCD allows easy conversion of computer output to denary display by representing each denary digit with its BCD
equivalent.
• Binary systems struggle to represent decimal values exactly, which is usually manageable except in cases like
monetary values where precision is critical.
• To avoid errors in monetary values, fixed-point notation (e.g., $1.31) is used, and each denary digit can be stored
as a BCD value.
• Consider adding $0.37 and $0.94 together using fixed-point decimals.

• Using binary addition, this sum will produce: 0 0 0 0 0 0 0 0 . 1 1 0 0 1 0 1 1 which produces 1 1 0 0 (denary 12)
and 1 0 1 1 (denary 11), which is clearly incorrect.
• The problem was caused by 3 + 9 = 12 and 7 + 4 = 11, as neither 12 nor 11 are single denary digits.
• The solution to this problem, enabling the computer to store monetary values accurately, is to add 0 1 1 0 (denary
6) whenever such a problem arises.
• If we look at the example again, we can add .07 and .04 (the two digits in the second decimal place) first.
Carry out these BCD additions.
a) 0.45 + 0.21
b) 0.66 + 0.51
c) 0.88 + 0.75
ASCII Codes and Unicode
• The ASCII code system, established in 1963 and updated in 1986, is a 7-bit character encoding standard used in
communication and computer systems, representing letters, numbers, and standard keyboard characters, along
with 32 control codes.
• 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)
• Unicode was developed as a global character encoding system to overcome the limitations of ASCII, supporting all
world languages and providing overlap with ASCII's first 128 characters while allowing for thousands more, using
up to four bytes per character.
• Established in 1991, the Unicode consortium aimed to create a universal, efficient, and unambiguous coding
standard, with each character encoded as 16-bit or 32-bit, addressing the inconsistency found in ASCII code
tables.
• Unicode includes provisions for private use, enabling users to assign codes for their own characters and symbols,
which is particularly useful for languages with extensive character sets like Chinese and Japanese.
Multimedia
• Bit Map Images
• Bit-map images are made up of pixels (picture elements); the image is stored in a two-dimensional matrix of
pixels.
• At least 8 bits (1 byte) per pixel are needed to code a colored image (this gives 256 possible colors by varying the
intensity of the blue, green and red elements)
• true color requires 3 bytes per pixel (24 bits), which gives more than one million colors.
• the number of bits used to represent a pixel is called the color depth.
• bit depth (The bit depth of a pixel determines its color depth, with higher bit depths allowing for more possible
colors; for instance, 8 bits per pixel can represent 256 colors, while 32 bits per pixel can represent over 4 billion
colors.)
• Image resolution refers to the number of pixels that make up an image; for example, an image could contain 4096
× 3192 pixels (12 738 656 pixels in total).
• Screen resolution is the number of horizontal and vertical pixels on a display, affecting image quality and visibility,
particularly if the screen resolution is lower than the image resolution.
• Pixel Density the number of pixels per square inch.
• Calculating Pixel Density, Imagine we are using an Apple iPhone 8 which has 5.5-inch screen size and screen
resolution of 1920 pixels × 1080 pixels:
• This gives us the pixel density of 401 pixels per square inch (ppi) (which is the same as the published figure from
the manufacturer).
• Calculating Bitmap Images File Sizes
• It is possible to estimate the file size needed to store a bit-map image. The file size will need to take into account
the image resolution and bit depth.
• For example, a full screen with a resolution of 1920 × 1080 pixels and a bit depth of 24 requires 1920 × 1080 × 24
bits = 49 766 400 bits for the full screen image.
• Dividing by 8 gives us 6 220 800 bytes (equivalent to 6.222 MB using the SI units or 5.933 MiB using IEE units).
• when saving a bit-map image, it is important to include a file header; this will 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.
• Vector Graphics
• Vector graphics use 2D points to define lines, curves, and geometric shapes, forming images based on their
properties.
• These graphics can be created with CAD software or applications that provide a drawing canvas on the screen.
• Each object in a vector graphic is defined by commands and attributes, such as position, size, line thickness, style,
color, and fill, which determine the object's properties.
• The relative positions of objects are specified without fixed dimensions, allowing the image to be scaled without
losing quality.
• Sound Files
• Sound travels through a medium by causing particle oscillations, which the human ear detects as sound; its
frequency and wavelength define the wave, while amplitude determines loudness.
• Sound, an analogue value, must be digitized using an analogue-to-digital converter (ADC) for storage in a
computer, often after filtering out frequencies outside the human hearing range.
• The digitization process involves sampling the sound waves at specific intervals, with approximate amplitude
values stored since precise measurements aren't possible.
• 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.
• File Compression
• File compression reduces file size to save storage or improve transmission speed, using two main methods: lossless
(preserving original quality) and lossy (reducing quality for smaller size).
• Lossless Compression
• Preserves all original data, allowing complete reconstruction of the file upon decompression, crucial for files where
data integrity is essential.
• Lossy Compression
• Removes unnecessary data, leading to some loss of detail; original file cannot be fully reconstructed. Examples
include MP3 and JPEG formats.
• 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.
• Unlike lossless compression, which retains all original detail, lossy compression prioritizes data reduction over
preserving every detail.
• File Compression applications
• MPEG-3 (MP3)
• MP3 Compression: Reduces audio file size by about 90% using perceptual music shaping, which removes inaudible
frequencies and quieter sounds, resulting in a lossy format where some original data is lost.
• An 80 MB music file on a CD can be reduced to 8 MB using MP3 technology.
• Bit Rate Impact: MP3 quality varies with bit rate; higher bit rates (e.g., 200 kbps or more) offer better sound quality
• MPEG-4 (MP4)
• MP4 Format: Supports multimedia files including music, videos, photos, and animations.
• Streaming Quality: MP4 files can be streamed online with minimal loss in quality.
• Music, videos, photos and animation can all be stored in the MP4 format.
• Photographic (bit-map) images
• JPEG Compression: Reduces both the file size and image quality; original files cannot be reconstructed post-
compression, with reduction factors between 5 and 15.
• SVG Compression: Scalable Vector Graphics (.svg) files are defined in XML text and can be compressed.
• RLE (Run Length Encoding)
• Run-length encoding (RLE) can be used to compress a number of different file formats.
• It is a form of lossless/reversible file compression that reduces the size of a string of adjacent, identical data (such
as repeated colours in an image).
• A repeating string is encoded into two values.
• The first value represents the number of identical data items (such as characters) in the run. The second value
represents the code of the data item (such as ASCII code if it is a keyboard character).
• RLE is only effective where there is a long run of repeated units/bits.
• Using RLE on text data
• Consider the text string ‘aaaaabbbbccddddd’.
• Assuming each character requires 1 byte, then this string needs 16 bytes. If we assume ASCII code is being used,
then the string can be coded as follows:

• This means we have five characters with ASCII code 97, four characters with 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 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).
• The original string contains 32 characters and would occupy 32 bytes of storage.
• The coded version contains 18 values and would require 18 bytes of storage.
• Introducing a flag (255 in this case) produces:255 08 97 255 10 98 99 100 99 100 99 100 255 08 101
• This has 15 values and would, therefore, require 15 bytes of storage. This is a reduction in file size of about 53%.
• RLE with images
• This produces the following data:

• The original image (8 × 8 square) would need 3 bytes per square (to include all three RGB values). Therefore, the
uncompressed file for this image is 8 × 8 × 3 = 192 bytes.
• The RLE code has 92 values, which means the compressed file will be 92 bytes in size. This gives a file reduction of
about 52%.
General Methods for file compression

You might also like