You are on page 1of 19

Images

Unit 1: Data representation

Computer Science
Section 1

4
Objectives
• Understand how a bitmap graphic is made up of
individual pixels
• Explain how each pixel is represented in binary
• Understand that the number of bits per pixel determines
the number of available colours for an image
• Explain the need for image metadata
• Explain the relationship between file size and image
resolution
Images
Unit 1 Data representation

Image file types


• BMP
• JPG
• GIF
• PNG
• TIF
Images
Unit 1 Data representation

Bitmap (or raster) images


• 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. 11111111 00000000 00000000 might equal Red
• A pixel’s colour can be changed by changing this value
Images
Unit 1 Data representation

Image resolution
• Resolution is the number of pixels within a
specific area
• The area of an image is expressed as its width and
height in pixels e.g. 3264 x 2448
• Screen resolution is expressed as pixels per inch (PPI)
• Print resolution is expressed as dots per inch (DPI)

1x1 2x2 5x5 10x10 25x25 50x50 72x72 300x300


Images
Unit 1 Data representation

Creating an Image
• Each pixel is given a 0 0 0 0 1 0 0 0 0 0
binary value 0 0 0 1 1 0 0 0 0 0
0 0 1 1 1 0 1 0 0 0
• Each value represents 0 1 1 1 1 0 1 1 0 0
a different colour 1 1 1 1 1 0 1 1 1 0

• Using one bit per pixel 0 0 0 0 1 0 1 0 0 0


1 1 1 1 1 1 1 1 1 1
allows only 2 values, 0
0 1 1 1 1 1 1 1 1 0
and 1
0 0 1 1 1 1 1 1 1 0
1 = Black, 0 = White 0 0 0 0 0 0 0 0 0 0
Images
Unit 1 Data representation

Increasing the number of colours


• More bits per pixel =
more possible colour
10 10
combinations
10 10 10 10
• 1 bit = 2 Colours 11 01 11 11 01
• 2 bits = 4 Colours 11 01 01 01 01 01

• 3 bits = 8 Colours 11 01 01 01 01 01
11 01 01 11
• 4 bits = 16 Colours
11 01 01 11 11
• How many bits per pixel 11 01 01 01 01 01 01

required for 256 colours? 01 = 10 =


00 = 11 =
Images
Unit 1 Data representation

Colours and resolution vs file


size 20 pixels

• How does the number


of colours affect file
size?

20 pixels
• How does the size of
the image affect file
size?

8 colours
Images
Unit 1 Data representation

.PBM file format


• The Portable Bitmap Image (pbm) file format is a
basic bitmap image file format in which each pixel is
represented by a byte that contains 1 or 0
• Black is represented by 1, white by 0
• The file can be opened in Notepad or a graphics package
such as Photoshop
Images
Unit 1 Data representation

Worksheet 4
• Now try the exercises in Tasks 1 and 2
Images
Unit 1 Data representation

Colour values

l
61 6 m
m 12
l
181ml
Images
Unit 1 Data representation

Looking at colour codes


• Colour values of individual pixels are expressed as
denary RGB values and in hexadecimal. Why not in
binary in this instance?
• RGB (Red, Green and Blue) values range between
0-255
• How many bits are required for 256 variations of each?
• How many bits altogether?
• In 32-bit colour what are the last 8 bits for?
Images
Unit 1 Data representation

Why file sizes don’t always add up


• DucksBMP: 1000 x 750
pixels
• 24-bit colour depth
• File size should be
1000 x 750 x 3 bytes
= 2,250,000 bytes
• Look at the file size in
File Properties
• Why is there a difference?
Images
Unit 1 Data representation

Image metadata
• Metadata is data about data
• It is information other than image data that is stored
with a file
• This will include:
• Colour depth in bits per pixel
• Resolution (Height and width in pixels)
• Date created
• Author

• How big is the DucksJPG file?


Images
Unit 1 Data representation

Image compression
• Reduces file size
• Two types:
• Lossy Compression (JPG)
• Lossless Compression (PNG)
Images
Unit 1 Data representation

Lossy compression
• Removes data permanently
• Tries to reconstruct an image without the missing data
• Much smaller file sizes but some loss of quality

380 KB 21 KB
Images
Unit 1 Data representation

Lossless compression
• Finds areas of the same colour and records them as
15 blue pixels rather than blue pixel, blue pixel, blue
pixel etc.
• 11011010,11011010,11011010,11011010 becomes
00000100-11011010
Images
Unit 1 Data representation

Worksheet 4
• Now try Task 3
Images
Unit 1 Data representation

Plenary
• A bitmap graphic is made up of individual
pixels
• Each pixel is represented in binary
• The number of bits per pixel determines the
number of available colours for an image
• The greater the image resolution, the larger
the file size

You might also like