data representation the method of data representation in a computer system depends upon the type of...

37
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

Upload: dominic-lindsey

Post on 30-Dec-2015

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 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

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. Numbers2. Text3. Graphics

Page 2: 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

The Binary System

Regardless of the type of data, all data is ultimately stored as binary numbers.

Two-state machineA computer is known as a two state machine because the processing and storage have two states only.

“On” or “Off”On – 1

Off – 0

Page 3: 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

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

Page 4: 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

Advantages of Binary1. Less arithmetic rules need to be built into the

computer, making calculations simpler.

e.g. only four rules:

0 + 0 = 00 + 1 = 11 + 0 = 11 + 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.

Page 5: 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

Units used in binary

Remember the units used in the binary system.

1 byte = 1 Kilobyte =

1 Terabyte =1 Gigabyte =1 Megabyte =

2048 Kilobytes = ?A. 1024 MegabytesB. 1 GigabyteC. 2 MegabytesD. 4096 bytes

8 bits1024 bytes1024 Kilobytes1024 Megabytes1024 Gigabytes

3 Gigabytes = ?A. 24 TerabytesB. 3072 MegabytesC. 24 KilobytesD. 3072 Terabytes

Page 6: 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

Converting between units

Recap Questions1. 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

Page 8: 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

Representing Numbers (Positive Integers)

When numbers are represented electronically, the base number is 2.

Convert binary numbers to decimal numbers

128 64 32 16 8 4 2 1

Convert the following 8 bit binary numbers:

1. 110010112. 011100103. 000000114. 11001101

27 26 25 24 23 22 21 20

Page 9: 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

Convert decimal to binary

128 64 32 16 8 4 2 1

Demo on board

Page 10: 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

Examples

1. 792. 353. 994. 103

Answers1. 010011112. 001000113. 011000114. 01100111

Page 11: 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

Representing Numbers (Negative Integers)

There are two method used to store negative numbers in a computer system.

Sign Bit

&

Two’s Complement

Page 12: 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

Two’s ComplimentThis is when the negative of a number is obtained.

Steps1. Find the positive binary number2. Change the 1’s to 0 and the 0’s to 13. Add 1

Example-351. Positive 35 = 001000112. Change the numbers = 110111003. Add 1 = 1101100

1-35 = 11011101

Page 13: 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

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

Page 14: 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

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)

Page 15: 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

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.

Page 16: 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

Range If you increase the exponent then you increase the range of numbers.

PrecisionThe 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.

Page 17: 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

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 allows additional characters.

Page 18: 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

Character SetThe set of characters represented by a computer. All numbers, letters and symbols.

Control CharactersASCII 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

Page 19: 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

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.

Page 20: 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

Unicode ASCII

Advantage Can store 65536 characters which can represent world wide languages

Only 8 bit code which takes up less storage than Unicode

Disadvantage A 16 bit code which will take up more memory

2^7 which represents only 128 characters

Unicode ASCII

Advantage Can store 65536 characters which can represent world wide languages

Only 8 bit code which takes up less storage than Unicode

Disadvantage

A 16 bit code which will take up more memory

2^7 which represents only 128 characters

Page 21: 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

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)

Page 22: 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

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.

Page 23: 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

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.

Page 24: 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

Advantages of Bit-Mapped

• Each pixel can be changed individually i.e. colour

• Edit a bit mapped graphic by deleting pixels anywhere on the image.

Disadvantages of Bit-Mapped

• 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.

Page 25: 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

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.

Page 26: 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

Advantages of vector images

• 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.

Disadvantages of vector images

• User cannot edit individual pixels

• Complex objects with many layers can demand a lot of storage space.

Page 27: 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

Resolution Refers to the number of pixels in the width and height of the image.

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 shade needs its own code.

1-Bit 2 Colours2-Bits 4 Colours8-Bits 256 Colours16-Bit 65536 Colours24-Bit 16 Million Colours (true colour)

Increasing the number of colours that are available increases the size of the code for each colour.

600 pixels

800 pixels

Page 28: 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

Calculation of memory and backing storage requirements for bit mapped image.

Formula

Storage requirements = total pixels number of bits used to represent colours or shades of grey

x

Page 29: 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

Calculating Memory

How much memory will the following screen require (Black & white)

• Calculate the total number of pixels

• Multiply by the number of bits per pixel

• Divide by 8 (to change into bytes)

Example 1

36 x 80 = 2880 pixels

2880 bits/8= 360 bytes

80 pixels

36 pixels

80 pixels

Page 30: 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

Calculating Memory

How much memory will the following screen require (Greyscale)

640 pixels

200 pixels

Example 2

640 * 200 = 128’000 pixels

128’000 * 2 = 256’000 bits

256’000/8 = 32’000 bytes

Greyscale uses 4 colours

2 bits per pixel

Page 31: 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

Calculating Memory

How much memory will the following screen require (Colour)

640 pixels

200 pixels

• Calculate the total number of pixels

• Multiply by the number of bits per pixel

• Divide by 8 (to change into bytes)

Example

640 x 200 = 128000 pixels/bits

640 x 200 x 8 (colour depth) = 1024000 bits/8

= 128000 bytes/1024

= 125 Kb

An image is 640 x 200 and has a colour depth of 8 bits. What is the storage requirements of this image?

Page 32: 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

Calculation storage requirements for a single image

7 pixels

5 pixels

Example 4

= (7 x 72) X (5 X 72)

= 504 X 360

= 181440 X 16

= 2903040 pixels/8

= 362880 bytes/1024

= 354.4 Kb

An image is 7 x 5 pixels, and each pixel can display 65536 different colours.

65536 colours = 16 bits

2^16

Page 33: 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

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.

Page 34: 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

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.

Page 35: 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

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

Page 36: 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

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 repeatedly throughout the graphic.

Page 37: 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

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.

MORE ABOUT THIS IN UNIT 3 - MULTIMEDIA