DIGITAL DATA
● Digital Data
○ Computers use 0 and 1 to represent data.
○ The binary numbers are refer as digital data.
● Text Data
○ Text or characters are represented in binary form.
○ Encoded using ASCII or Unicode to assign binary
codes to characters.
● Encoding
○ Encoding is the process of turning any real-world
2
information (images, sounds, text) into numbers(binary).
CHARACTER
ENCODING
ASCII CODES
4
ASCII CODES
● ASCII stands for American Standard Code for
Information Interchange.
● ASCII character encoding assigns a unique number to
letters, numbers and other printable characters like
spaces, commas and line breaks.
● Only works for English language.
5
ASCII CODES
● Represented using 7-bit binary – 128(27) possible values.
● Codes from 0 to 127 – can be written in decimal, binary or
hexadecimal.
● ASCII codes are in sequential groups:
○ 48 – 57: numbers 0 to 9,
0 is 48, 1 is 49…
○ 65 – 90: capital letters A to Z,
A = 65, B=66…
○ 97 – 122: small letters a to z,
a = 97, b=98…
○ 0 – 31: control Characters (backspace or enter)
6
Character
Decimal
Binary
Hexadecimal
A
65
1000001
41
Z
90
1011010
5A
a
97
1100001
61
z
122
1111010
7A
0
48
0110000
30
9
57
0111001
39
Space
32
0100000
20
!
33
0100001
21
7
ASCII CODES
● Example : in binary, “HELLO" would be represented as:
ASCII values H = 72,
E = 69,
L = 76,
O = 79
1001000 1000101 1001100 1001100 1001111
● a binary representation of a word that is three characters
long, using ASCII is
1000001 1010011 1000011
Find the characters
8
Calculating Text File Size
● Text file size depends on:
○ bits required to store each character.
○ total number of characters in the file
● 𝑇𝑒𝑥𝑡 𝐹𝑖𝑙𝑒 𝑆𝑖𝑧𝑒 𝑖𝑛 𝑏𝑖𝑡𝑠 = 𝑏𝑖𝑡𝑠 𝑝𝑒𝑟 𝐶ℎ𝑎𝑟𝑎𝑐𝑡𝑒𝑟 ×
𝑁𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝐶ℎ𝑎𝑟𝑎𝑐𝑡𝑒𝑟𝑠
● For ASCII, bits per character = 7 bits
9
LIMITATION OF ASCII CODES
● Additional Characters – does not support characters
with accents(French, Turkish characters).
● Other Characters – does not support Cyrillic
alphabets(Arabic characters).
10
LIMITATION OF ASCII CODES
● Non-alphabet Writing System - does not support
characters from other languages or writing systems like
Chinese, Japanese.
● Non-text Characters – does not support shapes and
symbols, icons, emojis.
11
UNICODE
12
UNICODE
● Unicode - Supports global languages, symbols, emojis.
● First 128 codes are same as ASCII (0 -127).
● Unicode can be represented using various bit sizes,
depending on the encoding scheme chosen like UTF-8,
UTF-16, UTF-32.
● It can represent more characters than ASCII, but
requires more storage space.
13
IMAGES
14
BITMAP IMAGES - PIXELS
● Images can be stored in computer in digital format(1 and
0).
● A bitmap image is made up of tiny dots.
● These dots are small square known as pixels(Picture
Elements).
● Each pixel is stored as a binary code.
● Each pixel has one colour assigned to it.
15
IMAGE SIZE
● Image size – Total number of pixels of a bitmap image.
● Calculated by multiplying the height and width of the
image in pixels.
● Higher image size, higher the quality of the image.
● Monochrome means using only 1 colour and white.
● Where 1 means colour and 0 means white.
16
IMAGE SIZE
Image size = height x width
= 7
x 5
= 35 pixels
17
The code for the 1st row is 00100
0
0
1
0
0
2nd row encoded as 01010
0
1
0
1
0
The image will be saved as
0
1
0
1
0
1
0
0
0
1
1
1
1
1
1
1
0
0
0
1
0
0
0
0
0
001000101001010100011111110001
00000
Example – To store pixel as bits
18
Example – To store bits into pixel
A bitmap image with binary data :
0111001010011100100001000
1
The image is 5 pixel wide and 5 pixel high.
1
Colour depth is 1 bit.
0
1
1
11 0
0
1
0
1
0
0
1
1
1
0
0
1
0
0
0
0
1
0
0
0
19
COLOUR DEPTH
● Colour depth – number of bits used to store colour
information.
● Colour depth is calculated as the number of bits assigned
to a pixel in an image.
● Image with high colour depth can use a lot of colours,
takes more space.
● Image with low colour depth can use a few colours,
takes less space.
20
COLOUR DEPTH
● Colour depth for black and white image would be 1 as it
uses 1 bit to represent the colour. (white 0, black 1)
21
COLOUR DEPTH
● Colour depth = 1 bit = 2 colours (1,0)
● Colour depth = 2 bits = 4 colours (00 01 10 11)
● Colour depth = n bits, number of colour used in the image
will be 2n
22
FILE SIZE
● File size = Colour depth(number of bytes used in colour
code) x image size(number of pixel).
File size = 7 x 7x 2
=98 bits
23
Impact of Colour Depth/
Image Size
● Higher the image size/colour depth, bigger the size of
the file, requires more storage space.
● Higher the image size - more pixels, clearer due to high
resolution.
● Higher the colour depth, more bits per pixel, more
colours.
24
IMAGE RESOLUTION
● Image resolution is the amount of dots/pixels that an
image contains to display the image and focuses on how
much detail that an image is capable of holding.
● An image with high resolution will be a lot higher in quality
and will appear a lot sharper.
● The higher the resolution of an image will mean the larger
the file size.
25
IMAGE RESOLUTION
● An image that is low of resolution will appear pixalated
and the quality will be very low.
● An image that is low in resolution will be smaller in size,
therefore making it more suitable for use on websites.
26
QUALITY of IMAGE
Based on resolution
Based on colour depth
DPI stands for dot per inch.
27
RGB COLOUR
● The RGB color model uses the three bytes for every pixel.
● colours: red, green, and blue
● Each byte can store color ranging from 0 to 255.
● 24-bit RGB colour code, a total of 256 intensities are
available, resulting in over 16.7 million possible colors
(256^3).
28
RGB COLOUR
● Red : 0 to 255 (The 1st byte stores the amount of red)
● Green: 0 to 255(The 2nd byte stores the amount of green)
● Blue: 0 to 255(The 3rd byte stores the amount of blue)
● Each color requires 8 bits and therefore the color depth of
an RGB images is 24 bits.
29
30
CLUT
● CLUT stands for Colour Look-Up Table
● Also known as Colour Palette.
● CLUT is a table that matched code numbers to colours.
CLUT shows the binary codes that are
assigned to colours – black, red, blue and
white respectively.
31
Example – To turn a bit sequence into a
colour image.
The first 14 bits in the sequence is 1110111011101110
The image is 7x7 grid of pixels.
2 bit colour code table is used.
1
1
1
32
Example – To turn a bit sequence into a
colour image.
The first 14 bits in the sequence is 1110111011101110
Since it uses 2 bit colour code,
1
split the bit into grous of 2 – 11-10-11-10-11-10-11
1
From CLUT : 11 = white, 10 = blue
1
The first row :
33
Example – To turn a colour image into a bit
sequence.
● Check the colour of first pixel in the image.
● Look up that colour in the CLUT.
1
● Add this binary number to the bit sequence.
1
● Repeat this process for every pixel.
1
Bitstream for the first row of the image
11000100110011
34
SOUNDS
35
ANALOGUE SOUND
● Sound in the real world is analog,
● represented as continuous variations (sound waves).
● To work with sound in digital devices, it must be converted
to a digital format.
● When audio is converted from analog to digital, it is
represented is a series of numerical values, typically
sampled at regular intervals.
36
ANALOGUE SOUND
● These samples capture the amplitude (loudness) of the
sound at each point in time.
37
ANALOGUE SOUND
● The height of the wiggly line
represents how loud the sound is
and is called the amplitude.
● The bigger the amplitude (i.e. the
taller the wave), the louder the
sound is.
38
ANALOGUE SOUND
● The number of waves that occur
in a period of time is called the
frequency.
● The higher the frequency (i.e. the
closer together the waves are), the
higher pitch the sound is.
39
40
SAMPLING
● Sampling is the process whereby an analogue wave is
converted into a digital signal.
● At specific intervals of time, measurements of the
amplitude of the wave are taken and stored as a binary
value.
41
SAMPLING
● Sample rate is the number of samples taken per second of
the analogue wave.
● The sample rate is measured in Hertz(Hz).
● 1 Hertz is equal to
1 sample of the
sound wave.
42
SAMPLING
● High sample rate –
○ more data,
○ more detail of the sound,
○ high frequency sound.
○ larger the file size.
○ The digital recording will be closer to the original
analogue sound.
43
SAMPLING
● Low sample rate –
○ less data,
○ less detail of the sound,
○ lower frequency sound.
○ less storage space.
○ The digital recording does not sound so realistic.
44
● The number of bits used to store an amplitude is called the
sample resolution/bit depth.
● Higher sample resolutions result in greater audio quality
but also increased file size.
● Bit rate : the number of bits used to store one second of
sound. = Sample Rate x Sample Resolution
45
FILE SIZE
● The size of a sound sample can be calculated by
multiplying together the duration of the sample in
seconds, the sampling rate in Hertz and the sample
resolution.
𝑆𝑜𝑢𝑛𝑑 𝐹𝑖𝑙𝑒 𝑆𝑖𝑧𝑒 𝑖𝑛 𝑏𝑖𝑡𝑠 = 𝑅𝑎𝑡𝑒 × 𝑅𝑒𝑠𝑜𝑙𝑢𝑡𝑖𝑜𝑛 × 𝑆𝑒𝑐𝑜𝑛𝑑𝑠
Or
𝑆𝑜𝑢𝑛𝑑 𝐹𝑖𝑙𝑒 𝑆𝑖𝑧𝑒 𝑖𝑛 𝑏𝑖𝑡𝑠 = Bit 𝑅𝑎𝑡𝑒 × 𝑆𝑒𝑐𝑜𝑛𝑑𝑠
46
FILE SIZE
● Example
a minute-long audio file sampled at 10 Hz with a sample
resolution of 24 bits would require.
𝑆𝑜𝑢𝑛𝑑 𝐹𝑖𝑙𝑒 𝑆𝑖𝑧𝑒 𝑖𝑛 𝑏𝑖𝑡𝑠 = 𝑅𝑎𝑡𝑒 × 𝑅𝑒𝑠𝑜𝑙𝑢𝑡𝑖𝑜𝑛 × 𝑆𝑒𝑐𝑜𝑛𝑑𝑠
=
10 ×
24
=
14400 bits
=
1800 bytes
× 60
47
FILE SIZE
● Example
a 3-minute long song with a sample rate of 44,100 Hz, and a
resolution of 24 bits would take up at least:
𝑆𝑜𝑢𝑛𝑑 𝐹𝑖𝑙𝑒 𝑆𝑖𝑧𝑒 𝑖𝑛 𝑏𝑖𝑡𝑠 = 𝑅𝑎𝑡𝑒 × 𝑅𝑒𝑠𝑜𝑙𝑢𝑡𝑖𝑜𝑛 × 𝑆𝑒𝑐𝑜𝑛𝑑𝑠
= 44100 x 24 x 180
= 190,512,000 bits
= 23,814,000 bytes
48
QUESTIONS AND
ANSWERS ?
49