AQA GCSE CSPaper 2 · Unit 3Lesson 8

Paper 2 · Unit 3 · CS-L3-08

Representing Images

60 minutes · AQA 8525 · Paper 2 — Fundamentals of data representation

Spec & Goals 3 min

AQA Spec 3.3.6 · Representing images

By the end of this lesson you can:

  1. Describe a bitmap image as a grid of pixels, each storing a colour in binary.
  2. Define resolution and colour depth, and link colour depth to 2n colours.
  3. Calculate an image's file size using width × height × colour depth.

Warm-Up 5 min

Last lesson you saw that every character is stored as a number in binary. Images are stored as numbers too.

Quick starter

A black-and-white image uses only 2 colours. How many bits does each pixel need?

Reveal the answer

1 bit0 for black and 1 for white. Two colours need only one bit, because 21 = 2.

Key Concept — pixels, resolution and colour depth 14 min

A bitmap image is a grid of tiny squares called pixels. Each pixel stores its colour as a binary number.

1 pixelwidth = 4 pixelsheight = 3
A 4 × 3 bitmap. Resolution = width × height in pixels = 4 × 3 = 12 pixels.

Colour depth gives 2n colours

If each pixel uses n bits, the image can show 2n different colours.

Colour depth (bits)Number of colours (2n)
121 = 2
222 = 4
424 = 16
828 = 256

Metadata

An image file also stores metadata — data about the image, such as its width, height, colour depth and the date it was taken.

Worked Example — calculating file size 12 min

Problem: a 10 × 8 image has a colour depth of 4 bits. Find its file size in bits and bytes.

Step 1 — write the formula.

QuantityValue
Width10 pixels
Height8 pixels
Colour depth4 bits/pixel

file size (bits) = width × height × colour depth.

Step 2 — substitute and work it out.

StepWorkingResult
Pixels10 × 880 pixels
Bits80 × 4320 bits
Bytes320 ÷ 840 bytes

Step 3 — check the colour depth meaning. A depth of 1 bit gives 21 = 2 colours; a depth of 8 bits gives 28 = 256 colours.

Try It Yourself 12 min

🟢 Easy

Goal: State how many colours an image can show with a colour depth of 3 bits.

Hint: the number of colours is 2n, where n is the colour depth.

🟡 Medium

Goal: Calculate the file size in bits of a 50 × 50 logo for a Penang café, stored at a colour depth of 2.

Hint: width × height × colour depth.

🔴 Stretch

Goal: A 100 × 100 image is stored at colour depth 8. Calculate its file size in bytes, then explain what happens to the size if the colour depth doubles to 16.

📝 Exam Practice 10 min

Answer the way the examiner expects — the command word and the marks tell you how much to write.

Calculate[2 marks]

Calculate the file size, in bits, of a 200 × 100 image with a colour depth of 3.

Mark scheme
  • 200 × 100 × 3 (1).
  • 60 000 bits (1).
Describe[2 marks]

Describe the effect on image quality and file size of increasing the colour depth.

Mark scheme
  • The image can show more colours, so quality / detail improves (1).
  • The file size increases / the file becomes larger (1).
Define[1 mark]

Define the term metadata as used for an image.

Mark scheme
  • Data about the image / data stored with the image, e.g. width, height, colour depth or date (1).
State[1 mark]

State the number of colours that can be represented by a colour depth of 4 bits.

Mark scheme
  • 16 (1) — because 24 = 16.

Recap & Key Terms 3 min

A bitmap is a grid of pixels, each storing a colour in binary. Resolution is width × height; colour depth is bits per pixel and gives 2n colours. File size (bits) = width × height × colour depth. Metadata is data about the image.

Bitmap
An image stored as a grid of pixels, each holding a colour as a binary value.
Pixel
One dot in the grid; the smallest part of a bitmap image.
Resolution
The width × height of an image, measured in pixels.
Colour depth
The number of bits used to store the colour of each pixel; n bits give 2ⁿ colours.
Metadata
Data about the image, such as width, height, colour depth and date.

Homework 1 min

Task (≤ 15 min): A photo of the Petronas Towers is 300 × 200 pixels with a colour depth of 8. Calculate its file size in bytes.

Model answer

300 × 200 × 8 = 480 000 bits (1). 480 000 ÷ 8 = 60 000 bytes (1).