#### Transcript Data Representation

```Data Representation
The method of data representation in a computer
system depends upon the type of data which is
being used.
Three types of data are considered at this stage:
1. Numbers
2. Text
3. Graphics
The Binary System
Regardless of the type of data, all data is ultimately
stored as binary numbers.
Two-state machine
A computer is known as a two state machine because
the processing and storage have two states only.
“On” or “Off”
On – 1
Off – 0
Why Binary?
The computer is a two-state (binary) machine. All
components inside a computer and all backing
storage devices have only two states. e.g.
• a switch is “on” or “off”
• a transistor conducts or does not conduct
• a signal is a pulse of electricity or no pulse
• an area of magnetic disk is positive or negative
• a laser can direct in two different directions
1. Less arithmetic rules need to be built into the
computer, making calculations simpler.
e.g. only four rules:
0
0
1
1
+
+
+
+
0
1
0
1
=
=
=
=
0
1
1
0 carry 1
2. Less chance of signal degradation as each line
carries a voltage or no voltage.
3. Two states are easy to represent in storage
devices.
e.g. the presence or absence of a pit oon the surface of a
CD-ROM.
Units used in binary
Remember the units used in the binary system.
1 byte =
1 Kilobyte =
1 Megabyte =
1 Gigabyte =
1 Terabyte =
8 bits
1024 bytes
1024 Kilobytes
1024 Megabytes
1024 Gigabytes
2048 Kilobytes = ?
A. 1024 Megabytes
B. 1 Gigabyte
☺C. 2 Megabytes
D. 4096 bytes
3 Gigabytes = ?
A. 24 Terabytes
☺B. 3072 Megabytes
C. 24 Kilobytes
D. 3072 Terabytes
Converting between units
Recap Questions
1. Gary uses a 2Gb memory stick to store is
music. How many 4.5Mb Mp3 files can Gary
store on his stick?
2 Gb = 2048/4.5 = 455 mp3’s
2. Calculate the file size of this black and white
image.
700 * 1200 = 840000/8
= 105000 bytes
= 102.5 Kb
1200
pixels
700
pixels
Representing Numbers
Numbers are classified as real numbers or integers.
Real Numbers (single)
All numbers including whole and
fractional.
e.g. 3.575
Integer Numbers
Whole numbers that can be positive
or negative.
e.g. -18, -98
Representing Numbers
(Positive Integers)
When numbers are represented electronically, the
base number is 2.
Convert binary numbers to decimal numbers
27
26
25
24
23
22
21
20
128
64
32
16
8
4
2
1
Convert the following 8 bit binary numbers:
1.
2.
3.
4.
11001011
01110010
00000011
11001101
Convert decimal to binary
128
64
32
Demo on board
16
8
4
2
1
Examples
1.
2.
3.
4.
79
35
99
103
1. 01001111
2. 00100011
3. 01100011
4. 01100111
Representing Numbers
(Negative Integers)
There are two method used to store negative
numbers in a computer system.
Sign Bit
&
Two’s Complement
Two’s Compliment
This is when the negative of a number is obtained.
Steps
1. Find the positive binary number
2. Change the 1’s to 0 and the 0’s to 1
Example
-35
1. Positive 35 = 00100011
2. Change the numbers = 11011100
1
-35 = 11011101
Floating Point Representation
Positive numbers – Positive Numbers can be converted
directly to their equivalent binary number.
Negative numbers - Two’s Complement
Real Numbers (decimal point) and very large numbers Floating Point Representation
Floating Point Representation is when two parts are used
to store a number.
M * base
M - Mantissa (actual number)
E - Exponent (power to which the base is raised)
Range
The range of numbers that can be stored depends on the
number of bits being used.
To find the range of numbers - calculate of the power and
half it. The positive range will be one less than the
negative range as it includes zero.
Range
If you increase the exponent then you increase the
range of numbers.
Precision
The more bits the more precise the mantissa will be.
If there is not enough bits set aside for the mantissa
the system has to round it down losing precision.
Representing Text
Each character has a unique 8 bit ASCII code associated
with it and this code is converted into binary before being
stored.
To store all the characters on a keyboard only 7 bits are
needed but very often 8 bits are used.
2^7 = 128 different characters
2^8 = 256 different characters – extended ASCII which
Character Set
The set of characters represented by a computer. All
numbers, letters and symbols.
Control Characters
ASCII characters that do not print on the screen in the
normal way. There are 32 special characters, for
example, Space bar, return, tab, cursor up
The increase in worldwide communication led to a need for
a larger standard code to cope with other foreign
alphabets, technical symbols etc.
Unicode
Designed to represent the writing schemes of all of the
world’s major languages.
Unicode is a 16 bit code and can represent 65536 different
characters.
Applications such as Office use Unicode in document files.
Mobile phones use Unicode to support all the different
symbols.
Unicode
ASCII
Can store 65536
Only 8 bit code
characters which
which takes up
canUnicode
represent
less storage than
ASCII
world wide
Unicode
Can store 65536 characters
Only 8 bit code which takes up
which can represent world wide
less storage than Unicode
languages
languages
16 bitbit
code which
will take up
2^7 which
represents
only 128
A Amore
16
code
2^7
which
memory
characters
which will take up represents only
more memory
128 characters
Representing Graphics
An image can be stored in memory in two ways:
Bit-mapped and Vector graphics
Bit-Mapped
An image on a computer screen is made up of tiny dots
called pixels. (Picture element)
Each pixel can be “on” or “off” depending whether the
value of the pixel in the computers memory is 1 or 0.
(Black & White)
Graphic Resolution
The smaller the size of pixels the finer the detail that can be
displayed on screen.
Small pixels = high resolution
Large pixels = low resolution
Problem!!
Increasing the resolution will increase the storage
requirements of the image.
Features of a Bit Mapped Image
Bit mapped packages paint pictures by changing the colour of
the pixels which make up the screen display.
A commonly known package used for bit mapped is a paint
package.
• Each pixel can be changed individually i.e. colour
• Edit a bit mapped graphic by deleting pixels anywhere on the
image.
• Bit-Mapped images require a large amount of storage
space, as every pixel is stored including white space.
• Does not take advantage of resolutions.
• Once they are enlarged to much, they look unnatural
and blocky. But reducing a picture too much also has a
bad influence as it looses sharpness.
Features of Vector Images
Object is represented by a series of object attributes. It
stores a description of the objects that make up the image.
It stores mathematical definitions of:
• The shape of graphic objects
• Their position on the screen
• Their attribute such as fill, line colour, pattern
The value of each of the objects attributes are stored in
memory as binary.
• Take up less storage space
• Do not lose their quality when resized
• Objects can be grouped to form larger objects
• Images are resolution independent. The picture will be
printed out at the full resolution available on the printer.
• User cannot edit individual pixels
• Complex objects with many layers can demand a lot of
storage space.
Resolution
Refers to the number of pixels in the width and height of the image.
800 pixels
600 pixels
Bit Depth
Refers to the number of bits needed to represent the colour of
each pixel. Greyscale simply means shades of grey and so each
1-Bit
2-Bits
8-Bits
16-Bit
24-Bit
2 Colours
4 Colours
256 Colours
65536 Colours
16 Million Colours (true colour)
Increasing the number of colours that are available increases the
size of the code for each colour.
Calculation of memory and backing storage
requirements for bit mapped image.
Formula
Storage requirements = total pixels
x
number of bits used to
represent colours or
Calculating Memory
How much memory will the following screen require (Black &
white)
• Calculate the total number of pixels
80 pixels
• Multiply by the number of bits per pixel
36 pixels
80 pixels
Example 1
36 x 80 = 2880 pixels
2880 bits/8= 360 bytes
• Divide by 8 (to change into bytes)
Calculating Memory
How much memory will the following screen require (Greyscale)
640 pixels
200 pixels
Greyscale uses 4 colours
2 bits per pixel
Example 2
640 * 200 = 128’000 pixels
128’000 * 2 = 256’000 bits
256’000/8 = 32’000 bytes
Calculating Memory
How much memory will the following screen require (Colour)
640 pixels
An image is 640 x 200 and has a
colour depth of 8 bits. What is
• Multiply
by the number
of bits per
the storage
requirements
ofpixel
this
200 pixels
image?
• Divide
by 8 (to change into bytes)
• Calculate the total number of pixels
Example
640 x 200 = 128000 pixels/bits
640 x 200 x 8 (colour depth) = 1024000 bits/8
= 128000 bytes/1024
= 125 Kb
Calculation storage requirements for a single image
7 pixels
5 pixels
An image is 7 x 5 pixels, and
each pixel can display 65536
different colours.
Example 4
= (7 x 72) X (5 X 72)
65536 colours = 16 bits
= 504 X 360
2^16
= 181440 X 16
= 2903040 pixels/8
= 362880 bytes/1024
= 354.4 Kb
Calculate the following
Question 1
Calculate the storage requirements of an image with 4 x 6
inches, has a resolution of 800 dpi and each pixel can
display 256 different colours.
Question 2
Calculate the storage requirements of an image with 8 x 12
inches, has a resolution of 1200 dpi and each pixel can
display 65536 different colours.
Question 3
An A4 image, at 10 x 8 inches, has to be scanned at 300 dpi
in 65536 colours. Calculate the storage requirements.
Image Compression
Images using 24-bit colour graphics will be of an extremely
high standard.
Images using 24-bit colour can require several megabytes of
memory for storage and can take time to transmit across a
network.
File compression can be used to reduce storage
requirements.
The result looks unchanged to the human eye.
Compression cont…
A process that reduces the number of bytes required to
define an image in order to save disk space or
transmission time.
Compression is achieved by replacing commonly
occurring sequences of pixels with shorter codes.
Solves the problem by:
• Reducing the file size
• Reducing the time taken to transmit the file across a
network
Types of Compression
There are two types of compression:
Lossless Compression
&
Lossy Compression
Lossless Compression
A lossless compression method reduces the size of the image
with no lost information. The decompressed image is exactly
the same as the original image.
No data is discarded. GIF is an example of lossless
compression.
How does it work?
Uses an algorithm to store patterns of bits that occur
Lossy Compression
Refers to data compression techniques in which some
amount of data is lost. Lossy compression technologies
attempt to eliminate redundant or unnecessary information.
JPEG is an example of this type if compression.