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

Unit 1-Data Representation

The document provides an overview of data representation, explaining the differences between analogue and digital data, and how computers store information in binary form. It covers various number systems including denary, binary, and hexadecimal, detailing conversion methods between them and their applications in computing. Additionally, it discusses the importance of binary and hexadecimal in programming, error codes, and HTML color codes.

Uploaded by

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

Unit 1-Data Representation

The document provides an overview of data representation, explaining the differences between analogue and digital data, and how computers store information in binary form. It covers various number systems including denary, binary, and hexadecimal, detailing conversion methods between them and their applications in computing. Additionally, it discusses the importance of binary and hexadecimal in programming, error codes, and HTML color codes.

Uploaded by

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

Data Representation

Chapter 1
By Farah Khaleeq
Data

•Data is raw facts and figures and can be in the form of


numbers, symbols or alphanumeric characters.
•Analogue Data is the smooth stream of data that our
senses process on daily basis such as sound waves. Humans
can process and understand analogue data as it is in the
continuous stream.
•Digital Data represents the values 1 and 0 that a
computer can process.
Data Representation
• Data representation is the method used within computer
system to represent information to be stored.
• Computers store different types of information including
Numbers, Text, Graphics and Audio.
• All types of information in a computer are stored internally
in a sequence of 0’s and 1’s (binary Form).
• Computers use numeric code to correspond to all the
information they store. These codes are based on binary
number system(base 2)
Key terms
BIT - A binary digit is referred to as BIT, its either 0 or 1
Nibble- It is made up of 4-bits. Used to represent one
hexadecimal digit in the form of binary
Byte - It is the unit of measurement of computer storage.
It is made up of 8-bits and represent a character/letter etc.
Common Number Systems
Denary Number Systems
• Denary number system has base 10 with digits 0,1,2,3,4,5,6,7,8 and 9. Denary
number system counts in multiples of 10..
• A decimal number 6357 can be expresses as
• (6 * 1000) + (3 * 100) + (5 * 10) + (7 * 1) = 6000 + 300 + 50 + 7 = 6357
• Another way to express it would be to use powers of 10. Assuming that we are
going to represent the concept of "raised to the power of" with the "^" symbol
(so "10 squared" is written as "10^2"), another way to express it is like this:
• (6 * 10^3) + (3 * 10^2) + (5 * 10^1) + (7 * 10^0) = 6000 + 300 + 50 + 7 = 6357
Binary Number System
• The Binary Number System consist of only two digits-0 and
1.
• Since this system uses two digits, it has the base 2
• All digital computers use this number system and convert the
data input from the decimal format into its binary equivalent.
• The following table is used for conversion.

7 6 5 4 3 2 1 0
2 2 2 2 2 2 2 2

128 64 32 16 8 4 2 1
Why Binary ?
• Since the computer is made up of electronic Components; it can have
only two states, either
• On(1)
• Off(0)
• The data which is given to the computer is converted into binary form
because a computer understands only binary language.
Converting Binary Numbers To Denary
Binary number is 10010101
1.Draw the following table using powers of 2

7 6 5 4 3 2 1 0
2 2 2 2 2 2 2 2
128 64 32 16 8 4 2 1

2. Only add the columns headings containing 1


=
Binary to Denary Page 4.
C.W(a-e) H.W(f-j)
7 6 5 4 3 2 1 0
2 2 2 2 2 2 2 2

128 64 32 16 8 4 2 1

Answers
a. 51
b. 127
c. 153
d. 116
e. 255
Denary To binary : Method 1
• Place 1 in the appropriate positions so the total becomes the denary
number:
• To convert 107 into binary place 1 in the columns 64,32,8,4,2 and 1
because and fill rest of the columns with 0 because
107=64+32+8+2+1

128 64 32 16 8 4 2 1
0 1 1 0 1 0 1 1
Decimal to Binary :Successive Division :
Method 2

Answer
Binary number is : 11001
Page 7. C.W(a-e) H.W(f-j)

a. 101001
b. 1000011
c. 1010110
d. 1100100
e. 1101111
Uses of Binary numbers

The microprocessor makes use of transistors that identify voltage levels only i.e.
‘1’ for ‘on’ and ‘0’ for ‘off ’ . That’s why binary numbers are used.
Binary numbers are used in registers. A register is a small piece of memory
where values can be held.
In a digital instrument, a register might be used to convey whether the device is
sending a signal to the computer, 1 or 0.
For example, a robot arm that has various motors to perform different
operation, for example , raise the arm, open the grip and close the grip. Each
motor works via a signal, 1 for on, 0 for off. A register is used for each motor to
convey the signal.
The Hexadecimal System

• The hexadecimal system is closely related to binary number.


• Hexadecimal system is base 16 system therefore it has 16-digits, which are
0-9 and A-F
A = 10
B = 11
C = 12
D= 13
E = 14
F = 15
Link between Binary, hexadecimal and Denary
Binary to Hexadecimal

An equally easy way to convert from binary to hexadecimal is to group


binary digits into sets of four, starting with the least significant (rightmost)
digits and use the nibble heading for each group
8 4 21 8421
Binary: 11100101 = 1110 0101
8+4+2 4+1
14 (E) 5
Add up the headings which have 1 under them
Hexadecimal = E5

17
Page 9. C.W(a-e) H.W(f-j)

a. C3
b. F7
c. 27F
d. 4EE
e. 1E1
Hexadecimal To Binary

For each hex number write equivalent binary number by using the tables given below
(i.e. writing 1’s below the numbers which add up to make the given hex number)

8 4 2 1 8 4 2 1
0 1 0 1 1 1 0 1
5 D is 13
19
Page 10. C.W(a-e) H.W(f-j)

a. 01101100
b. 01011001
c. 10101010
d. 10100000000
e. 010000001110
Why hexadecimal numbers
are used instead of Binary?

• Programmer work with hexadecimal as it is easier for human to read


than binary.
• They are shorter to represent as 1 byte can be represented by 2 hex as
compared to 8 bits binary.
• Programs written in hexadecimal are easier to debug than those
written in binary.

21
Converting Hexadecimal To Denary

Converting hexadecimal to decimal can be performed in the conventional


mathematical way, by showing each digit place as an increasing power of
16. Of course, hexadecimal letter values need to be converted to decimal
values before performing the math.
A 2 D hexadecimal:
= (A* 16 2) 1 0
+ (2 * 16 ) + (D* 16 )
= (10 * 162) + (2 * 161) + (13 * 160)
= (10 * 256) + (2 * 16) + (13 * 1)
= 2560 + 32 + 13
= 2605 denary
Page 11. C.W(a-e) H.W(f-j)

a. 107
b. 156
c. 74
d. 255
e. 511
Converting Denary to
Hexadecimal
To convert from denary to hexadecimal involves successive division by 16 until the
value “0” is reached. The only addition to the algorithm when converting from
denary to hexadecimal is that a table must be used to obtain the hexadecimal digit
if the remainder is greater than decimal 9.

24
Denary to Hexadecimal
Conversion

16 423
16 26 7
16 1 10(A) Hexadecimal Number= 1A7
0 1

25
Denary to Hexadecimal
Conversion : Example

Convert 16879 to Hexadecimal number


Decimal
Operation Quotient Remainder
Number
16879 16 1054 F (15)

1054  16 65 E (14)

65  16 4 1

4  16 0 4
Hexadecimal Number : 41EF
26
Page 12. C.W(a-e) H.W(f-j)

a. 62
b. E3
c. 1EA
d. 1FF
e. 33A
Uses of the hexadecimal numbers

Error codes
Media Access Control
IPv6 addresses
HTML colour codes

28
Error Codes
• Error codes refer to the memory location of the error and
automatically generated by the computers.
• These error codes are often shown in hexadecimal values.
• The programmer needs to know how to interpret error codes
Error Codes from a Windows System
Media Access Control(MAC)

• MAC address refers to a number which uniquely identifies a device


on internet. The MAC address referred to the network interface
card(NIC). It is a permanent address.
• Hexadecimal numbers are used for MAC addresses.
• It is made up of 48 bits which are shown as 6 groups of two hex
digits
• MAC Address
NN-NN-NN-DD-DD-DD
Manufacturer ID Device serial Number
00-1C-B3-4F-25-FE

• Apple corporation(001CB3)
31
Internet Protocol (IP) Addresses

• IP address is an address given to a device when it is connected to the


internet.
• IPv4 address is a 32-bit number written in denary or hexadecimal form.
• Example 109.108.158.1
Or
77.76.9e.01 (hex)
• IPv4 has recently improved upon by adoption of IPv6, which is 128 bit
number broken down into 16-bits chunks represented by a hexadecimal
number
Hyper Text Mark-up Language

Hyper Text Mark-up Language is used in


development of web pages. Note that it isn't a programming language, but a
mark-up language.
A mark-up language is used in the processing, definition and presentation
of text.
A markup language is interpreted by browser
HTML uses <tags> which are used to bracket code
For example, <title> starts the title of HTML document and </title > is
used to end it.
<title>My Web Page</Title>
Hex is used as a notation for colour in HTML.
33
HyperText Mark-up Language (HTML) colour
codes
• HyperText Mark-up Language (HTML) is used when writing and developing
web pages.
• HTML isn’t a programming language but is simply a mark-up language.
• A mark-up language is used in the processing, definition and presentation
of text
Example : To Specifying the colour of the text
HTML uses <tags> which are used to bracket a piece of text for example,
<h1> and </h1> surround a top-level heading. Whatever is between the two
tags has been defined as heading level 1. Here is a short example of HTML
code:
Colour Codes In HTML
HTML is often used to represent colours of text on the computer screen. All
colours can be made up of different combinations of the three primary
colours (red, green and blue). The different intensity of each colour (red,
green and blue) is determined by its hexadecimal value. This means different
hexadecimal values
represent different colours. For example:
» # FF 00 00 represents primary colour red
» # 00 FF 00 represents primary colour green
» # 00 00 FF represents primary colour blue
» # FF 00 FF represents fuchsia
» # FF 80 00 represents orange
» # B1 89 04 represents a tan colour,
Structure of An HTML Program
Binary Addition

Binary Addition Carry Sum


0+0 0 0
0+1 0 1
1+0 0 1
1+1 1 0
Addition of 3 Binary Digits
Binary Addition Carry Sum
0+0+0 0 0
0+0+1 0 1
0+1+0 0 1
0+1+1 1 0
1+0+0 0 1
1+0+1 1 0
1+1+0 1 0
1+1+1 1 1
Page 16. C.W(a-e) H.W(f-j)

a. 10000011
b. 01100110
c. 01111011
d. 1011011
e. 01101111
Page 16. C.W(a-e) H.W(f-j)

a. 01110001(113)
b. 01110101(117)
c. 10010101(149)
d. 11011110(222)
e. 10010111(151)
Overflow error

• A CPU with a capacity of 8 bits has a capacity of up to 11111111


in binary. If one more bit was added there would be
an overflow error.
Example: 8-bit overflow
• An example of an 8-bit overflow occurs in the binary sum
11111111 + 1 (denary: 255 + 1).

• The total is a number bigger than 8 digits, and when this


happens the CPU drops the overflow digit because the
computer cannot store it anywhere, and the computer
thinks 255 + 1 = 0.
When an overflow error happens?

• Overflow errors happen when the largest number that a register can hold
is exceeded. The number of bits that it can handle is called the word size.
• Most CPUs use a much bigger word size than 8 bits.
• The greater number of bits which can be used to represent a number then
the larger number that can be stored.
• A 16-bit register would allow a maximum denary value 65535(216 −1)
Classwork C.W Act 1.10

2b. 10111001111100100
Logical Binary shifts

• The logical shifts means moving the binary number to the


left or to the right.
• Left shift is equivalent to multiplying the binary number by
2,
• Right shift is equivalent to dividing the binary number by 2,
What happens to the empty position
when a bit is shifted?
• As bits are shifted any empty positions are replaced with zero.
• There is a limit to the number of shifts which can be carried out if
the binary number is stored in an 8-bit register.
• After a number of shifts the register would only contain zeros
Classwork C.W Act 1.11 Q 1

a. 104
b. 26 number is divided
by 22
c. 15
d. 240 number is
multiplied by 24
Home Work [ Act 1.11 pg. 20]
Submission : Before next class
Two’s complement

• A method of representing signed numbers is two's


complement.
• Most computers use this method to represent negative
numbers.
• This method can be more effective when performing
mathematical operations like adding and subtracting.
How sign of number is determined using Two’s
complement?
• With two's complement, the left-most bit determine the
sign of the binary number .
• 1 in the left-most bit indicates a negative number
• 0 in the left-most bit indicates a positive number
• For a 8-bit number the left most bit is changed to a negative
value, so it is -128 instead of 128.
• New range of possible numbers is -128 (10000000) to
(01111111)
-128 64 32 16 8 4 2 1
Method to determine Two’s
complement
1. Complete the number of bits by adding zeros to the left
2. Invert the binary number
3. Add 1
Converting positive binary numbers in 2’s complement
format to positive denary numbers

Example 3 pg. 22
Convert 01101110 in two’s complement binary into denary
-128 64 32 16 8 4 2 1

Example 4 pg. 23
Convert 00111111 in 2’s complement binary into denary
-128 64 32 16 8 4 2 1
Classwork Act 1.12 pg. 23
1. Convert the following positive denary numbers into 8-bit binary
numbers in 2’s complement format:
a. 39
b. 66
e. 111
f. 125

a. 00100111
b. 01000010
e. 01101111
f. 01111101
Classwork Act 1.12 pg. 23

a. 85
b. 51
c. 76
d. 126
Writing Negative binary numbers in two’s complement format
Classwork Act 1.13 pg. 25

a. 11101110
b. 11100001
c. 11010001
d. 11000001
e. 10101000
f. 10100100
g. 10011100
h. 11111111
i. 11110000
j. 10000001
Homework Act 1.14 pg. 25
1.2.1 Character Set
• The list of binary codes that can be recognised by computers
as being usable characters.
• Text and numbers can be encoded in a computer as patterns
of binary digits. Hexadecimal is a shortcut for representing
binary.
• Types of character sets
1. ASCII code
2. Unicode
ASCII CODE

American standard code for information exchange, used in


communication systems and computers
7-bit codes(0 to 127 or 00 to FF IN hex) that represents the letters,
numbers and other characters found on the keyboard.
Control codes are from 0 to 31
In order to convert between uppercase and lowercase letters only
invert sixth bit that is at 32nd position
Character sets (e.g. a to z, 0 to 9, etc.) are grouped together in
sequence, which speeds up usability.
Conversion between uppercase and
lowercase letters
64 32 16 8 4 2 1

97

65
Disadvantages of ASCII

It does not represent characters in non-Western languages, for


example Chinese characters.
There are different versions of ASCII as DOS and windows use
different character for some ASCII Code
Extended ASCII

• It uses 8-bit codes (0 to 255 in denary or 0 to FF in hex ).


This gives another 128 codes to allow characters of non-
English alphabets and graphical characters
Unicode

• It represents all languages of the world.


• It supports many operating systems, search engines and internet
browsers.
• First 128 character for ASCII and Unicode are same but Unicode
support several thousand different characters
• ASCII Code uses 1 byte to represent a character whereas Unicodes
supports 4 bytes per characters
Goals for developing Unicode System

Create a universal standard that covered all languages and all


writing systems
Produce more efficient coding system than ASCII
Adopt uniform encoding where each character is encoded as 16-
or 32 bit code.
Create unambiguous encoding where 16 bit and 32 bit represent
the same character thus creating unambiguous encoding
Reserve part of the code for private use to enable a user to assign
codes for their own character
1.2.2 Representation of Sound

Soundwaves are vibrations in the air. The human ear


senses vibrations and interpret them as sound.
Each sound wave has a frequency, wavelength and
amplitude. Amplitude specifies the loudness of the
sound.
Sound is analogue because sound wave vary.
Computer cannot work with analogue data therefore
sound need to be sampled in order to store in the
computer.
Sampling is measuring the amplitude of the sound
wave. This is done using ADC.
To convert the analogue data to digital, the sound
waves are sampled at regular interval
High and low frequency wave signals
Amplitude range = 0  10 [ 0000 1010] Binary
Number of bits in a sample = 4
Sampling resolution(Bit depth) = 4 (bits per sample)
Increasing the number of possible values used to represent 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).
1.2.2 Representation of Sound
• Sampling Resolution/bit depth : Number of bits per
sample
• Sampling rate : Number of sound samples taken per second.
It is measured in hertz(Hz)., where 1 Hz means one sample per
second
CDs have a 16-bit sampling resolution and 44.1 kHz sample rate, that is
44100 samples per seconds
How sampling is 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
Each sample of sound wave is then encoded as a series of binary
digits
Benefits and drawbacks of using
larger sampling resolution
1.2.3 Representation of bitmap images

Bitmap images are made up of pixels


An image is made up of 2D matrix of pixels.
Each pixel can be represented as a binary number, and so a
bitmap image is stored in computer as a series of binary number
1.2.3 Representation of bitmap images

Image Type Bits per pixel Possible colours each Bit combinations
pixel has
Black And White 1 2 0 or 1
Coloured 2 4 00, 01, 10, 11
Coloured 3 8 000,001, 010,…….,
111
Colour Depth

• The number of bits used to represent each colour is called colour


depth. 8 bit colour depth means each pixel can be one of 256
colours(as 28 = 𝟐𝟓𝟔)
• Modern computers have 24 bit colour depth, which means over 16
millions different colours can br represented.
Image resolution

• Image resolution Number of pixels that make up an image.


• For example an image could contain 4096 x 3072 pixels(12582912
pixels in total)

Image ‘A’ has the highest resolution and É’has the lowest resolution
Drawbacks of using high resolution images

Increase in file size, as number of pixels used to represent the


image is increased
Less images can be stored
It takes more time to download an image from internet
It takes more time to transfer image from one device to another
1.3.1 Measurement of data storage

BitA basic unit of computer storage (is either 1 or 0). The word
comes from binary digit.
ByteSmallest unit of memory in a computer. 1 bytes = 8 bits
Nibble it has 4 bits – half a byte
1 byte of memory wouldn’t allow to store much information so
memory size is measured in multiples
1.3.1 Measurement of data storage

This table is inaccurate as it is based on the SI (base 10) system of units


where 1 kilo is equal to 1000 . According to this table 1TB =1012
1.3.1 Measurement of data storage

Since memory size is measured terms of powers of 2 therefore another


system has been adopted by IEC(International Electrotechnical
Commission) based o binary system
• 1 kibibyte ( 1 KiB ) - 1 024 bytes
• 1 mebibyte (1 MiB ) =1024 KiB= 1 048576 bytes
• 1 gibibyte ( 1 GiB ) =1024 MiB = 1 073 741824 bytes
• 1 tebibyte (1 TiB ) = 1024 GiB = 1099511627776 bytes and so on.
IEC memory size system

This system is accurate. Internal memories(RAM and ROM) should be


measured using this system
Estimating size of an image

Storing a simple black-and-white image


Storing a simple 8-bitcolour image
Calculating a file size from image size and resolution
Calculation of File size of an Image

File size (image)=Image resolution (in pixel ) * colour depth(in bits)


Example : Storing a simple black-and-white image

The graphic contains 8 rows and 8 columns


Colour depth = 1 pixel (A black and white image requires 1 bit per pixel)
Resolution (in pixels) = 8 X 8 = 64 pixels
File size = 64 pixels * 1 bit per File size in bits= 64 bits
File size in bytes = 64 /8=8 bytes
Storing a simple 8-bit colour image

The graphic contains 8 rows and 8 columns


Resolution =8*8=64 pixels
Color Depth = 8 bits (Graphic is in 8-bit colour).
One pixels requires 8 bits (1 byte).
File size(in bits) = 64 pixels X 8 bits = 512 bits
File size(in bytes) = 512 /8 =64 bytes
Calculating a file size when image size and resolution
are given

Calculate the file size for a 24-bit colour image


that is 2 inches high and 3 inches wide, with a
resolution of 300 dots per inch.
• First, the number of pixels are calculated. If the resolution
is 300 dots per inch then the pixel grid for a 2-inch by 3-inch
image will measure 600 pixels (2 X 300) by 900 pixels (3 X
300).
Key terms related to Audio files
Sampling Resolution/ Sample Depth is no. of bits per sample

Sampling rate is the number of sound samples taken per second


measured in hertz(Hz) where 1 Hz means ‘one sample per second’.

CDs have a 16bit sampling resolution and 44.1 kHz sample rate,
which is 44100 samples per second
Calculating The Size Of An Audio File
There are four main pieces of data that are used in calculating the size of
an audio file:
• The length of the audio track (this needs to be in seconds)
• The number of samples taken per second (sample rate)
• The number of bits used to store each sample (sample depth)
• The number of channels used to play the track (mono has 1, stereo has 2)
• following calculation can then be carried out to find the size of the file:
Formula to calculate Audio file size

File size =sample rate x sample depth x track length x


number of tracks
Activity 1.16 Q 4 :Audio file size calculation
Example
If an audio track is 3 minutes and 30 seconds (210 seconds in
total) in length, recorded in stereo, samples at 44 Khz (44000 Hz)
with a sample depth of 16 bits, find the file size. Calculate how
many typical songs could be stored on 740 MiB CD

File size = sample rate x sample depth x track length x number of tracks

File size (in bits) = 44000 X 16 X 210 X 2 = 295680000 bits


File size (in bytes)= 295680000/8 = 36960000 bytes
File size (in KBs) = 36960000/1024 = 36093.75 kilobytes
File size (in MBs) = 36093.75 /1024 = 35.25 megabytes
Total songs = 740/35.25
Data Compression
• Data compression is Storing data in a format that requires less
space than usual.
• When data other than text is being transmitted, e.g. on the
Internet, it is important to limit the amount of data that needs
to be sent to reduce the time taken to download the data being
unreasonably long.
• The amount of data can be limited by reducing the file size of
pictures so that they take up only a small part of the screen or
restricting them to a few colours.
• Speeding up the transmission of the data is achieved by reducing
the amount of data that is sent. This is known as file
compression.
How Data Compression is Done?
• Data compression is done by using compression (algorithms that
manipulate the data).

• These algorithms normally manipulate the data so that repeating data


is removed, either on a temporary or a permanent basis, depending
on the method used.

• Compression can be either lossy or lossless. Lossless compression


means that no data is lost.
Why use Compression ?
• To save storage space on devices such as the hard disk /solid state
drive
• To reduce the time taken to stream a music or video file
• To reduce the time taken to upload, download or transfer a file across
a network
• Upload and download process uses up network bandwidth-this is the
maximum rate of transfer of data across a network, measured in bits
per second. Compressed files use less bandwidth, which results in
faster data transmission.
Types of Compression
• Lossy
• Lossless
Lossy Compression
• Lossy compression simply eliminate "unnecessary" bits of information
using file compression algorithm. The data is removed permanently, so it
is effectively ‘lost’.
• Lossy is derived from the word ‘loss’ and this refers to the way this
method of compression works.
• It is impossible to get the original file back once it is compressed.
• Lossy compression is mostly used for multimedia such as audio, video
and image files.
• This type of compression is used a lot for reducing the file size of bitmap
pictures and MP3 files , which tend to be fairly bulky.
Lossy Compression
• This is mostly done when streaming these files, as a file can be
streamed much more effectively if it is smaller in size.
• If a lossy compression method is used on a music file it will try to
remove all background noise and noises that may not be heard by the
human ear.
• This data isn’t hugely necessary for playing the track; removing it will
mean the track will not sound exactly as it did when recorded, but it
will be a very close representation
Lossy Vs. Lossless Compression
Common Lossy file Compression algorithms
• MPEG-3(MP3)
• MPEG-4(MP4)
• JPEG
Image Compression Using Lossy Compression
• Lossy compression will reduce the file size further by removing detail
from the image that should go unnoticed and will not affect the
quality too much.
• One issue with using some lossy compression methods on images, is
that the method will remove a little bit of detail each time the image
is saved in the compression method e.g. JPEG.
• This means that there will be a small loss in quality each time it is
saved.
JPEG
• When camera takes a photograph, it produces a large bitmap file that
is temporary. JPEG is a lossy file compression used for bitmap images.
• After applying JPEG Compression algorithm a new file is form and the
original file can’t be reconstructed.
How JPEG Compression is done
• Human eye don’t detect differences in colour shades quite as well as
they detect differences in image brightness
• By separating pixel colour from brightness, image can split into 8x8
pixel blocks, which allows certain information to be discarded from
the image without causing loss of quality
How MP3 compression is done
• Removal of sounds outside the human ear range
• If two sounds are played at the same time, only the louder can be
heard, so softer sound is eliminated. This is called Perceptual
Music Shaping.
MP4
• MP4 files are slightly different to MP3 files. This format allows the
storage of multimedia files rather than just sound-music, videos,
photos and animation can all be stored in MP4 format.
• It uses lossy format and retains the quality of sound and music
• For example movies could be streamed over the internet using MP4
format without the loss of quality
Lossless Compression
• Lossless refers to a method of compression that loses no data in the
process.
• In lossless compression, the compressed data can be reversed to
reconstruct the data file exactly as it was.
• Lossless compression is used when it is essential that no data is lost
or discarded during the compression process.
• There are many different lossless compression algorithms; most work
using a shorthand to store the data that can be then reconstructed
when the file is opened.
Lossless Compression
• With the lossless file compression, all the data bits from the original
file are reconstructed when the file is again uncompressed.
• This is particularly important for files where loss of any data would be
disastrous-for example spreadsheet file.
Lossless Compression with Text Files: Example 1
• Lossless compression can also be used when storing text
files.
• Consider the following message:
WHEN IT IS SNOWING HEAVILY LOOK OUTSIDE.
LOOK OUTSIDE IT IS SNOWING HEAVILY.
• Total characters = 62
• Storage = 62 bytes
Look up Table WHEN IT IS SNOWING HEAVILY
LOOK OUTSIDE.
Instead of storing all 62 LOOK OUTSIDE IT IS SNOWING
characters individually, we could HEAVILY.
instead store the words and the
positions at which they occur in
the message, in a lookup table:
When we store the message this
time we need 1 byte for each
I byte for each position the word
occurs in the message:
Result of Compression
File size = 33+13=46 bytes
Original file = 62 bytes
Reduction = 26%
Image Compression Using Lossless
Compression
Both the Lossy and lossless methods of compression reduce the size of
an image by looking for repeating colour patterns within the image.

For example, for an image that has a main background colour that is
the same throughout the image, a compression method will recognise
that there are a lot of pixels that all have the same value and collate
them.

This means they will be stored as a single data value with further data
that records the pattern.
Audio Compression Using Lossless
Compression
• When the music track is played, the full track, exactly as it
was recorded, can be reconstructed and listened to.
• People may use lossless compression when downloading a
music track if they want the highest quality possible and to
hear the track exactly as it was recorded.
Run-Length Encoding(RLE)
• RLE can be used for lossless compression of a number of different file
formats
Using Run-Length Encoding on Text Data
• Compress the string ‘aaaaabbbbccddddd’
• No. of characters = 16
• Storage = 16 Byte
• RLE code storage = 8 bytes
Characters ASCII code Number of time
a 97 (1 byte) 05 (1 byte)
b 98 (1 byte) 04 (1 byte)
c 99 (1 byte) 02 (1 byte)
d 100 (1 byte) 05 (1 byte)
Total = 8bytes 4 bytes 4bytes
Using RLE with Images: Black & White
Coloured Image

Storage of image = 8x8x24=192 bytes


RLE code = 92 bytes

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy