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

Chapter 1, Part 3

Uploaded by

verfixjack
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Chapter 1, Part 3

Uploaded by

verfixjack
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 32

Data Representation

Text, Sound and Images


Contents
Representation of Text

Representation of Bitmap image

Representation of Sound
Used 3 denary digit as code

possible combination = 2 no of bit


000
001 21 = 2 ( 0 or 1) possible combination
002
. 22 = 4( 00 -- 11) possible combination
.
. 27 = 128 ( 0000000 -- 1111111) possible combination
999
28 = 256 ( 0000000 0-- 11111111) possible combination
= 000--999 = 1000 possible
combination
Representation of Text

Character Set- ASCII code and Unicode


Character Set- ASCII code and Unicode
• Computers can only recognize binary.
• Thus, all letters, numbers and various symbols are encoded and stored as pattern of binary digit in
computer.
• When a key are pressed on a keyboard, binary number are generated that represent a symbol for
that key
Character Set
A defined list of characters recognized by a computer’s software and hardware

‘A’ represents as
binary :
01000001 128 64 32 16 8 4 2 1

‘A’ represents as 0 1 0 0 0 0 0 1
denary number:
65
Character Set- ASCII code and Unicode
ASCII code (American Standard Code for Information Interchange)

 The ASCII code consisted of 7 bits and so 128 characters could be represented.

 All of the lower and upper case English characters, punctuation marks and control
actions (backspace, shift an so on) were represented.
ASCII code
Table

0 to 32 control
Action
Character Set- ASCII code and Unicode
Extended ASCII code

 Extended ASCII uses eight bits, giving a character set of 256 characters.

 This allows for special characters such as © ě and those with accents in languages
such as French and Spanish.

Disadvantages of ASCII code


 ASCII can represent 128 characters because it use 7 bits per character
 Thus, it only represent English language
 This does not represent characters in non-Western Languages ( Chinese ,
Japan ,Myanmar)
 There was no standardization (making things of the same type have the same basic
features)
Character Set- ASCII code and Unicode
Unicode (American Standard Code for Information Interchange)

 To overcome the problem of ASCII code, the Unicode was founded to develop and
promote a Unicode system

 Unicode uses 16 bits or 32 bits per character, so it can represent characters from
languages from all around the world.

 As it is larger than ASCII, it might take up more storage space when saving
documents.

 Global companies, like Facebook and Google used Unicode


How to calculate text file size

Text file size = number of characters * number of bits per character

The txt file contains 200 characters and use 7 bits to represent each
characters. Calculate the txt file size in bit and byte.

Text file size = number of characters * number of bits per character

= 200* 7
= 1400 bits
= 1400 bits / 8
= 175 bytes
Representation of Image
Representation of Bitmap Image
 The bitmap image are made up of pixels
 An image is made up of two dimension matrix of pixels
 Each pixel is represented as a binary number and so a bit map image is stored in a
computer as a series of binary number

Pixels
Short for picture
element, the
smallest single point
of color in an image
Representation of Bitmap Image
The number of different colors that can be decided by the number of bits used to encode
color.
Binary representation of bitmap
For example image
if 1 bits is used for each pixel 1 1 0 1 1 0 1 1
1 1 0 1 1 0 1 1
21 = 2 (two color) Black and white 1 1 0 1 1 0 1 1
1 1 0 1 1 0 1 1
0 Black 1 1 0 0 0 0 1 1
1 White
1 1 0 0 0 0 1 1
1 1 0 1 1 0 1 1
1 1 0 1 1 0 1 1
1 1 0 1 1 0 1 1
Representation of Bitmap Image
 Many images need to use colors.
 To add color, more bits are required for each pixel.

2 bits per pixel = 22 = 4 (0-3) (00-11) = 4 possible colors

3 bits per pixel = 23 = 8 (0-7) (000-111) = 8 possible colors

4 bits per pixel = 24 = 16 (0-15) (0000-111) = 16 possible colors

Color depth
The number of bits used to represent/encode the
color of each pixel is called color depth.

00 10 8 bit color depth= 8 bit per pixel =28 =256 colors


The effect of Color depth
01 11 As the color depth increase so does the number of
colors that can be represented
Representation of Bitmap Image
• The current standard represents the color of each pixel in 24 bit.
• There are 8 bits for each of the red, blue and green primary colors

0000 0000 0000 0000 0000 0000


To
1111 1111 1111 1111 1111 1111
28 = 256 * 28 = 256 * 28 = 256 = 16777216

• There are 256 variations of each primary colors( RGB) and that give 16 millions different
color.

True Color
True color is the specification of the color of a pixel using a 24 bit value for
the RGB color which allows the possibility of 16 million colors.
Representation of Bitmap Image
Image size and resolution
 Image size is usually written as two number , for example 100 * 66 , 4288 * 2824
 The first number indicates the number of pixels along the width of the image and the second
number is the number in the height.

Resolution
The number of pixel
per inch when the
image is displayed

3 pixel per inch

 This images are the same size but different in resolution.


 There are different number of pixel per square inches in the two images
 Each pixel in the 100 * 66 image is larger size than those of 4288 * 2824 images. 6 pixel per inch
 The greater the number of pixel within the given area the higher the resolution
Representation of Bitmap Image
How to calculate file size of bitmap Image
• The file size for bitmap image is calculate by finding the number of pixels and
multiplying that by the number bits used to represent each pixel (color depth)

The file size of image =Width * Height * Color depth


Representation of Bitmap Image
Example
Create expressions and calculate the file size of the following images
Express the sizes in bits and bytes
(a) A true color (24 bit) used image with a size of 640 * 480

File size of image (in bit) = width * height * color depth


= 640 * 480 * 24
= 7372800 bit

File size of image (in byte) = 7372800 / 8

= 921600 byte
Representation of Bitmap Image
Example
Create expressions and calculate the file size of the following images
Express the sizes in bits and bytes
(b ) A 256 color image with a size of 640 * 480 pixels

color depth(or) number of bit per pixel =?


256 colors = 28
color depth(or) number of bit per pixel = 8 bit
File size of image (in bit) = width * height * color depth
= 640 * 480 * 8
= 2457600 bit

File size of image (in byte) = 2457600 / 8

= 307200 byte
Representation of Bitmap Image
Exercise
Create expressions and calculate the file size of the following images
Express the sizes in bits and bytes
(a) A photograph is 1024 * 1080 pixels and use a color depth of 32 bit
(b) The image with 2048 * 2048 pixel and use a color depth of 4 bit
(c) A 32 color image with a size of 240 * 480
Representation of Bitmap Image
What is metadata of image?
• Files contain extra data called metadata. Metadata includes data about the
file itself, such as:
 file type
 date created
 Author
 The height and width of the image
 Resolution
 Color depth
• Without this metadata, the image data would not be correctly displayed.
Exercise
• An image is 2322 pixels high and 4128 pixels wide. The image is stored with a 16-bit colour depth.
The metadata for the image is 975 bytes. Construct an expression to show how the file size, in
bytes, is calculated.
File size = File size of image + The metadata of image

File size of image = 2322 * 4128 * 16 (Bit to byte)


8
File size =19170432 + 975
=19171407 bytes
Representation of Sound
Representation of Sound

• All sound are caused by vibration in air.


• The human ears sense these vibration
and interpret them as sound. Time
• Each sound wave has a frequency,
wave length and amplitude
• The amplitude specifies the loudness of
sound.
Wavelength
• Sound wave vary continuously
• Thus, the sound wave is analogue.
Representation of Sound

Digital Recording
 Computer cannot work with
analogue so the sound wave need
to be sampled in order to be stored
in computer.
 Sampling means measuring the
amplitude of the sound at regular
time interval.
Benefits
 The sampling are done by Analogue  Equipment to record and process digital sound is
to Digital converter (ADC) to convert relatively cheap and has allowed people to record
analogue to digital. music at home

 To convert analogue to digital, the  It is easily edited using computer equipment


sound wave are sampled at regular
 It is easily copy
time interval.
Representation of Sound
Sample Resolution or Bit Depth
The number of bit per sample is
known as the sampling resolution or
bit depth.

Sample Rate/ Sample frequency


Sample Rate is the number of
sound samples taken per second.
This is measured in herz (Hz)
Time interval (in sec)

1 2 3 4 5 6 7 8 9 10
Sample (denary) 8 3 7 6 9 7 2 6 6 6
Sample (Binary) 1000 0011 0111 0110 1001 0111 0010 0110 0110 0110

0 –10 = 2 4 = 4 bit per sample Eg.


The range of sound sampled is 0 to 10. Thus Bit depth = 4 bit
4 bit per sample is used. Sample rate = 1 Hz per second
Representation of Sound
3 Hz per second
Digital sound
wave

Analogue sound signal


The effect of Sample Rate
The higher the sample per second , the
higher the quality of sound ( fidelity) and
the larger the file size.
The effect of Bit Depth
The higher the number of bit per sample,
the greater the quality of sound (fidelity) For CD recording a bit depth of 16 bit
and the larger the file size and 44.1 kHZ (44100) Hz per second
Representation of Sound

Calculation of Digital audio file sizes


The size of a digital audio sound file depends on the followings
• Sample rate per second
• Bit depth
• Duration of recording (in sec)
• Number of channel – mono ( one channels) or stereo (two channels)

File size of digital audio file = sample rate(Hz) * bit depth * duration(in seconds ) * number of channels
Representation of Sound

What is the file size of a stereo recording of three minutes duration with a sample rate of
44100 and a bit depth of 24 bits? Give your answer in bit and bytes

Number of channels = 2
Duration = 3 min and 35 s
= (3*60)+35
Duration = 3 min = 3* 60 = 180
4 kHZ per second chage Hz
Sample rate per second = 44100 per second = 4000 hz per
second
Bit Depth = 24 bit

File size = 44100 * 24 * 180 * 2

= 381024000 bit Or 381024000/ 8 = 47628000 byte


Exercise
1.John eventually records the music in mono with a sample rate of 44.1 kHz and a bit
depth 16 bit. If the recording last for 2 minutes. Calculate the size of the file produced.
Express your answer in bytes.

= (44.1*1000) * 16 * (2*60)* 1 /8
better sound quality or
Larger file size

3 bits
1. Explain the term image resolution
2. The software developer is using 16-colour bitmap image.How many bits would be used
to encode data for one pixel of his image
3. The image is 512 pixel wide and 382 pixel height. He decide 256 color bitmap image.
Calculate the file size in byte.

You might also like