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

5 04092023191225 C NumberSystem Lecture Part 2

The document discusses data representation of text, images, and sound. It describes how characters are represented using character sets like ASCII and Unicode. It explains how images are represented using pixels, color depth, and resolution. Each pixel is assigned a binary value representing a color. More bits per pixel allows more colors. Sound is represented by sampling the amplitude of sound waves at regular intervals, with each sample represented by binary values. Higher sampling rates and depths improve sound quality but increase file size. Data storage sizes are measured in bytes, kilobytes, megabytes, etc. and file sizes can be calculated from image/sound properties.

Uploaded by

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

5 04092023191225 C NumberSystem Lecture Part 2

The document discusses data representation of text, images, and sound. It describes how characters are represented using character sets like ASCII and Unicode. It explains how images are represented using pixels, color depth, and resolution. Each pixel is assigned a binary value representing a color. More bits per pixel allows more colors. Sound is represented by sampling the amplitude of sound waves at regular intervals, with each sample represented by binary values. Higher sampling rates and depths improve sound quality but increase file size. Data storage sizes are measured in bytes, kilobytes, megabytes, etc. and file sizes can be calculated from image/sound properties.

Uploaded by

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

Chapter - 1

Data Representation

Handout: Part - 2
Number System:
Text, sound and images:
Character set :

 A list of characters (ASCII character set consist of 7 bits i.e. 0 to 127 denary, 00 to 7F in
hexadecimal number).
 It consists of letters, number, symbols of standard keyboard.
 It has been defined/recognized by computer hardware and software .

ASCII – ASCII code is coding system for all the characters on an English standard keyboard and
control codes (Ctrl, Alt, Shift…., Esc, Fn)
 A unique numerical or denary value of each key of English standard keyboard. Like A : 65
 ASCII originally uses seven (7) bits to encode each character. 27=128 characters
Extended ASCII uses 8 bits codes:

 The characters from 0 to 255 =256 in denary or 00 to FF in hexadecimal


 Used to represent non-English alphabets & some graphical characters
Unicode: Key of all the foreign languages other than Key of an English standard keyboard
 Each character is encoded between 32, 16, and 8-bit encodings.
 Unicode has greater range of characters than ASCII.
 Unicode is used for internet searching and browsing & support many operating systems.
Disadvantages of using ASCII code:

• Only 128 (if 7 bits) / 256 (8 bits) characters can be represented


• Many characters used in other languages cannot be represented in different systems
• Uses values 0 to 127 (or 255 if extended form) / one byte

Disadvantages of ASCII is Overcome by Unicode:

• Uses 16, 24 or 32 bits / two, three or four bytes


• Unicode is designed to be a superset of ASCII
• Most characters (in other languages) can be represented

1
Chapter - 1
Data Representation

Image

• Bitmap images are made up of PICture ELement or PIXELS

• A pixel is the smallest identifiable area of an image

• Each pixel is a single colour and is given a binary value which represents that colour e.g. 11000000 might
equal Red

• A pixel’s colour can be changed by changing this value

• Pixels are small blocks of addressable areas and the color they have is represented by binary & stored as
bits

• Total no. of pixel (resolution of image) = Width x Height

• Each Pixel is given a binary value

• Each value represents a different colour

• Using one bit per pixel allows only 2 values, 0 and 1

1 = Black, 0 = White

0 0 0 0 1 0 0 0 0 0

0 0 0 1 1 0 0 0 0 0

0 0 1 1 1 0 1 0 0 0

0 1 1 1 1 0 1 1 0 0

1 1 1 1 1 0 1 1 1 0

0 0 0 0 1 0 1 0 0 0

1 1 1 1 1 1 1 1 1 1

0 1 1 1 1 1 1 1 1 0

0 0 1 1 1 1 1 1 1 0

0 0 0 0 0 0 0 0 0 0

2
Chapter - 1
Data Representation

Increasing the number of colours:

More bits per pixel = more colour combinations

• 1 bit = 2 Colours (21 i.e. which is equal to 2)

• 2 bits = 4 Colours (22 two multiple by itself twice 2x2 )

• 3 bits = 8 Colours (23 two multiple by itself thrice 2x2x2 )

• 4 bits = 16 Colours

Image Resolution: the amount of pixels an image contains per inch or per centimeter/area in unit.

• Resolution is the concentration of pixels within a specific area

• The area is defined by the image width and height in pixels e.g. 3264x2448

1x1 2x2 5x5 10x10 25x25


50x50 72x72 300x300

Colour depth: number of bits used to represent the color of a single pixel.

E.g. a 1 bit image can only store 2 to the power 1 pixels which equals to 2. Therefore, a 1 bit image is
monochromatic o

An image with n bits has 2 power of n colours per pixel

• The higher the colour depth, the better colour quality

• The higher the colour depth, the larger the file size/requires higher storage.

• Uploading and downloading takes time

• File size = Total No. of Pixel × Colour Depth

Calculation of file size:

The file size of an image is calculated by

image resolution (number of pixels) × colour depth (in bits)

The file size of a sound file is calculated by:

sample rate (in Hz) × sample resolution (bits) × length of sample (secs)

3
Chapter - 1
Data Representation

Image files size calculation:


For example, a photograph is taken by a camera that uses a colour depth of 32 bits; the photograph is
1024 × 1080 pixels in size. We can work out the file size as follows:

1024 × 1080 × 32 = 35 389 440 bits ≡ 4 423 680 bytes ≡ 4.22 MiB
For example, an audio file which is 60 minutes in length uses a sample rate of 44 100 and a sample
resolution of 16 bits. We can work out the file size as follows:

44100 × 16 × (60 × 60) = 2 540 160 000 bits ≡ 317 520 000 bytes ≡ 302.8 MiB

4
Chapter - 1
Data Representation

Q3. How many bits per pixel required for 256 colours?

………………………………..

5
Chapter - 1
Data Representation

SoundASCII & Binary Coded Decimal (BCD)

Sound:
Definition & characteristic

 Sound is an analogue value needs ADC to be digitized/binary


 Binary number of each sample & store in order
 Each sound wave has a frequency and wavelength;
 The amplitude specifies the loudness of the sound

Sampling Rate/sampling interval:

 Number of samples taken per second/unit time. How often the computer takes a measure of the
sound.
 A higher sampling rate means the waveform will be converted from analog to digital form more
accurately.

Sampling Resolution (bit depth): Number of bits assigned to each/per sample

 The sampling resolution allows you to set the range of volumes storable for each sample
 The quality of a sound produced using a sound sampler depends on the sampling rate and sampling
resolution.
 Higher sampling rate/resolution means larger file size
 Example : a 16 bit sampling resolution is used when recording CDs to gives better sound quality.

Sound in analogue form can be represented by wave forms;


The height/amplitude of these waves can be sampled regularly with the height/amplitude being
represented by a bit-code/binary values

Bit Rate:
 Number of bits required to store 1 sec of sound. How many bits are used for each sample (bps).
 Higher bit rates result in higher quality of sound but also higher storages requirement.
 Bit Rate= Sample Rate (in Hz) x sample resolution(in bits) x Length of Sound sample (in
sec)

6
Chapter - 1
Data Representation

How is sampling used to record a sound clip?

 The amplitude of the sound wave is first determined at a set time intervals (sampling rate)
 This gives approximate representation of the sound wave.
 The sound is encoded as a series of binary digits and stored in order.

The pros and cons of using a larger sampling resolution when recording sound

Pros Cons
Larger dynamic range Produces larger file size
Better sound quality Takes longer to transmit/download sound file
Less sound distortion Requires greater processing power

Recording sound using software: Common Features of software include the ability to:…..

Activity:

Data storage and compression


Measurement of data storage:

 4 bits=Nibble
 8 bits =1 bytes
 1024 bytes=1 KiB
 1 KiB (kibibyte) = 210 bytes
 1 MiB (mebibyte) = 220 bytes
 1 GiB (gibibyte) = 230 bytes
 1 TiB (tebibyte) = 240 bytes
 1 PiB (pebibyte) = 250 bytes
 1 EiB (exbibyte) = 260 bytes

Calculation of file size:


The file size of an image is calculated by:
image resolution (number of pixels) × colour depth (in bits)

For example, a photograph is taken by a camera that uses a colour depth of 8 bits; the photograph is 1000 ×
200 pixels in size.

We can work out the file size as follows:

7
Chapter - 1
Data Representation

1000 × 200 × 8 = 1600000 bits (pixel)


1600000 bits / 8
200000 bytes / 1024
=195.3125KiB
Answer : 195 KiB

The file size of a sound file is calculated by:

sample rate (in Hz) × sample resolution (bits) × length of sample (secs).

For example, an audio file which is 3 minutes in length uses a sample rate of 44 100 and a sample
resolution of 16 bits. We can work out the file size as follows:

44100 × 16 × (3 × 60) = 127008000 bits


127008000 bits / 8
=15876000 bytes / 1024
=15503.90 KiB / 1024
=15.14 MiB
Answer : 15 MiB

File/Data compression techniques/algorithm


It is technique/method/program to compressed/reduce the file size.

Lossless file compression Lossy file compression


Eliminates unnecessary bits of data in original file,
All the data bits from the original file are
impossible to get the original file back once it is
reconstructed when the file is again uncompressed.
compressed.
This is particularly important for files where loss of It is chosen for files where removing certain bits
any data would be disastrous. doesn’t detract from the quality.

Example: a spreadsheet file, text file, txt, docx,


Example : MP3/MP4 and jpeg formats
programming source code
Other unnecessary or redundant information is
Remove the data bits temporarily
removed permanently.
Lossy does not allow original file to be re-created
exactly
It is used as replacement technique for example
Run Length Encoding (RLE).
• by example: 000–1111–222222–333 Lossy techniques make decision about what parts
= 3-0, 4–1, 6–2, 3–3 of data would be removed or not.
000-1111-222222-333
3 zeros (0), 4 one (1) ….

None of the original data is lost File size reduction is greater than using lossless.

The file needs to be of high precision & accuracy. The file may not need to be of high precision &
accuracy.

8
Chapter - 1
Data Representation

How lossless algorithm work

Run Length Encoding (RLE):

 A repeating string is encoded into two values.


 The first value represents the number of identical data items/characters in the run.
 It is a lossless algorithm.

Run length encoding (RLE) is an example of lossless compression. It works by:

 reducing the size of a string of adjacent, identical data items


 the repeating unit is encoded into two values:
o first value represents number of identical data items
o second value represents code (such as ASCII) of data item.

How lossy algorithm is used to reduce a image file.

For Image:

 Remove the unnecessary/redundant information/data permanently


 Reduce the pixel width/height, (size)
 Reduce the image resolution
 Reduce the colour depth/bit depth

For audio/sound:

 Reduce the sample rate


 Reduce the sample resolution

End of handout

You might also like