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

Data Storage and Compression

The document discusses data storage and compression, explaining the difference between decimal and binary prefixes for measuring storage capacity. It covers methods for calculating file sizes for images, audio, and other data types, as well as the principles of lossless and lossy compression techniques. Additionally, it highlights the advantages and disadvantages of compression, including its impact on file quality and the necessity for compatible software for processing.

Uploaded by

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

Data Storage and Compression

The document discusses data storage and compression, explaining the difference between decimal and binary prefixes for measuring storage capacity. It covers methods for calculating file sizes for images, audio, and other data types, as well as the principles of lossless and lossy compression techniques. Additionally, it highlights the advantages and disadvantages of compression, including its impact on file quality and the necessity for compatible software for processing.

Uploaded by

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

Data Storage and Compression

Data Storage

1 MB = 106 = 10 3 * 103 = 1000 * 1000 1 MiB = 220 = 2 10 * 210 = 1024 * 1024


Internation System of Measurement The international Electrotechnical
(Deciaml Prefix) Commission IEC (Binary Prefix)
It use power of 10 (eg 10 3 for 1000) It use power of 2
It multiples a unit by power of 10 It multiples a unit by power of 2
Data Storage

 As computer are binary, the binary prefix is the most exact, but the decimal prefix units
are sill used because it is far more easier to multiply and divide by 1000 than it is by 1024

Example
A hard disk is described as having a storage capacity of 1.5 TB . What is that in megabytes

a storage capacity = 1.5 TB


Decimal prefix
a storage capacity (in MB) = 1.5 * 1000 (1000)
Byte
= 1500 GB * 1000 KB
= 1500000 MB MB
Another Method GB
TB
a storage capacity (in MB) = 1.5 * 1000 * 1000
= 1500000 MB
Data Storage

An image file has a file size of 363143213 bits. Create an expression to convert this size to
mebibytes (MiB) and show the results.

File size (in mebibytes) = 363143213 / 8 = 45392902 byte / 2 20


Binary prefix (1024)
= 45392902 / 1024 * 1024 Byte
KiB
= 43 MIB MiB
GiB
TiB
File size (in mebibytes) = 363143213 = 43 MiB
8 * 1024 * 1024
• 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
megabytes, is calculated. You do not need to do the calculation
File size = File size of image + The metadata of image

File size of image = 2322 * 4128 * 16


8
2322 * 4128 * 16 + 975
8

2322 * 4128 * 16 + 975


8

1000 * 1000
• A photograph is 1024 * 1080 and use color depth of 32 bits. How many photographs of
this size would fit onto a memory stick of 64 GiB.

The size of photograph (in byte) = 1024 * 1080 * 32


8

= 4423680 Byte

The size of memory stick (in byte) = 64 * 2 30

= 64 *1024 * 1024 * 1024

= 68719476736 Bytes

The number of photographs would = 68719476736


fit onto a memory stick = 15534 Photo
4423680
An audio CD has a sample rate of 44100 and a sample resolution of 16 bits. The music
being sampled uses two channels. Calculate the file sizes for 60 minute recording in MB.

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

File size of digital audio file (in MB) = 44100 * 16 * (60*60) * 2


= 5080320000 bit
8

= 635040000 byte

106
= 635040000 byte
1000 * 1000

= 635 MB
Exercise
1. A hard disk is described as having a storage capacity of 1.5 TB . What is that in kilobyte
.
2. A camera detector has an array of 1920 by 1536 pixels. A color depth of 16 bit is used.
Calculate the size of photograph take by this camera, given your answer in MB.
3. Photographs have been taken by a smartphone which uses a detector with a 1024*
1536 pixel array. The software use color depth of 24 bits. How many photographs
could be stored on a 640 MB memory card?
4. The typical song stored on a music CD is 3 minutes and 30 seconds. Assuming each
song is sampled at 44100 Hz and 16 bits used per sample. Each song utilizes two
channels. Calculate how may typical songs could be stored on a 740 MiB.
Compression
The sound and image file size can be very large.
Therefore it is necessary to reduce ( or compress) the size of file for the following reason
• To save storage space
• To reduce transmission time

Compression : Changing the format of a data file so that the size of the file become smaller.
There are two type of compression
• Lossless
• Lossy
Compression

Lossless compression
• When lossless compression is used, no data is lost and the original file can be
restored.
• This is particularly important for files where any loss of data would be disastrous
• Lossless compression is used for text file and executable file (source code) as
missing data would completely change the meaning so that it could not be
understand.
Compression
Lossless Compression
Run-Length Encoding (RLE)
• RLE is used to reduce the size of a repeating string of items.
• Is a form of lossless file compression
• The repeating string is called a run and is represented by two bytes :
• The first byte represents the number of times the item of information is repeated.
• The second byte represents the item of information
• RLE is only effective where there is a long run of repeated unit/bit.
• The file may not be compressed very much at all if the characters are not repeated.

Example One byte per each letter is


used to encode.
cccmmmmmsssssdddcccccc = 22 byte

RLE version
3c5m5s3d5c = 10 byte
Compression

• Run-Length Encoding
• For black and white image, RLE would be effective
• A color image in which there are very short runs of different colors would not be encoded
as effectively. Code RLE Size of Code
version
wwbbbwww 2w3b3w
wwbwwwww 2w1b5w
wwbwwwww 2w1b5w
wwbbbwww 2w3b3w
wwbbbwww 2w3b3w
wwwwbwww 4w1b3w
wwwwbwww 4w1b3w
wwbbbwww 2w3b3w
To demonstrate RLE, the letter w and b are
used to represent as white and black.
Compression

Lossy Compression

 It decrease file size by deleting some of the data.


 Therefore, the original file cannot be re-formed entirely when it is decompressed.
 It cannot not used with text or program files
 It can be used for bitmap image and audio file where we often cannot notice that data
has been removed.

BitMap Image
 A lossy Compression algorithm analyses all of the data in the image.
 When it find tiny color differences, it give them the same colors value and then it can
rewrite the file using fewer bits.
 It reduce resolution and color depth in image.
 JPEG with extension jpg use lossy compression.
Compression

Lossy Compression

Audio File
 Much of the data in an audio file
encodes tone and frequencies that
our ears cannot hear and small
differences in volume and frequency.
 The lossy compression remove this
redundant and excess data
 MP3, MPEG,MP4 used lossy
compression
MP3
• Is a format of digital audio
• Is AUDIO (Lossy) COMPRESSION format to convert music and other sounds
into an MP3 file format.
• will reduce the size of a normal music file by about 90 per cent.

How to compress sound file


• Compression algorithm is used
• Use PERCEPTUAL MUSIC SHAPING which removes sounds that the human ear can’t
hear properly.
• The sample rate and sample resolution could be reduced
• if two sounds are played at the same time, only the louder one can be heard by the ear,
so the softer sound is eliminated.
• Unnecessary data are permanently eliminated and the original file is lost after
compression.
MP4
• Uses similar technology as MP3.
• Allow the storage of multimedia files such as Music, videos, photos and
animation can all be stored in the MP4 format
• Video streaming on internet are usually in MP4 format.

How to compress Video file

A compression algorithm is used


The resolution and color depth could be reduced
Use PERCEPTUAL MUSIC SHAPING which removes
sounds that the human ear can’t hear properly.
Disadvantages of compression
 Can affect the quality of the file
 Compressing / decompressing the file takes execution
time
 Both compressing and decompressing have to be
done with compatible software

You might also like