Images

GCSE Computer Science (OCR) · OCR J277 · Computer systems (Paper 1) › Memory and storage › Data storage

60 exam-style questions plus unlimited generated ones on this topic, at up to four difficulty levels, with full mark schemes. Notes and past-paper booklets are open to everyone. Practice needs a free account.

Or take a quick quiz: 11 questions on this subtopic in GCSE Computer Science (OCR), marked as you tap.

Revision notes

How a bitmap image is stored as a grid of pixels, with each pixel's colour held in binary, plus metadata. You need to explain how colour depth and resolution affect image quality and file size, and calculate file sizes. Expect definitions, questions on turning a small image into binary, and non-calculator file size calculations.

Key facts

  • Pixel: a single dot of colour in a bitmap image
  • Colour depth: number of bits per pixel
  • Number of colours = 2colour depth (1 bit = 2, 4 bits = 16, 8 bits = 256)
  • Resolution: number of pixels in the image (width × height)
  • File size (bits) = colour depth × width × height
  • Metadata: data about the image, e.g. width, height, colour depth
  • More pixels or more bits per pixel → better quality but a larger file

Notes

Pixels and colour depth

diagram
  • A bitmap image is made up of a grid of pixels (picture elements). Each pixel is a single colour.
  • The colour of each pixel is stored as a binary code. With 1 bit per pixel only 2 colours are possible, e.g. 0 = white and 1 = black.
  • 10001100011111110001100011 = filled, 0 = empty (1 bit per pixel)
    Each pixel's colour is a binary code; this 5 × 5 image needs 25 bits of pixel data
  • Colour depth is the number of bits used to store the colour of each pixel. n bits give 2n colours: 1 bit → 2, 2 bits → 4, 8 bits → 256, 24 bits → about 16.7 million.
  • Resolution is the number of pixels in the image, often given as width × height, e.g. 1920 × 1080.

Metadata

  • Metadata is data about the image, stored in the file along with the pixel data.
  • It includes the width and height (in pixels) and the colour depth, so the computer knows how many pixels are in each row and how many bits to read for each pixel.
  • It can also include the date and time the image was created, the location, the camera settings and the file format.

Quality and file size

diagram
  • Higher resolution: more pixels, so more detail and a sharper image that looks less blocky (pixelated) when enlarged, but a larger file.
  • 6 × 6 = 36 pixels12 × 12 = 144 pixelsblocky, smaller filemore detail, bigger file
    Higher resolution: more pixels, so more detail but a larger file
  • Higher colour depth: more possible colours, so more realistic colours and smoother shading, but every pixel uses more bits, so a larger file.
  • File size (bits) = colour depth × width × height. E.g. an image 200 × 100 pixels at 8 bits: 200 × 100 × 8 = 160,000 bits; ÷ 8 = 20,000 bytes = 20 KB.
  • The actual file is slightly larger than this because it also stores metadata.
  • Changes multiply: doubling both the width and the height gives 4 times as many pixels; doubling the colour depth as well gives 8 times the file size. Grade 8+ only

How to answer each type of question

Define the key terms and explain metadata

1 to 2 marks eachGrade 4
  1. Give precise definitions: colour depth is bits per pixel, not 'the number of colours'.
  2. For metadata, say what it is (data about the image), give examples, and say why it is needed.

Example. (a) State what is meant by colour depth. [1]
(b) Explain why metadata is stored in an image file. [2]

Show the model answerHide the model answer
(a) The number of bits used to store the colour of each pixel
(1)
(b) Metadata stores information such as the width, height and colour depth of the image (1), so the computer knows how to display the image correctly, e.g. how many pixels are in each row and how many bits to read for each pixel
(1).

Represent an image in binary and choose a colour depth

2 to 5 marksGrade 5
  1. Use the key given: write one code per pixel, row by row.
  2. For a number of colours, find the smallest power of 2 that is big enough.
  3. Explain using 2n.

Example. A 4 × 3 pixel image uses 1 bit per pixel, where 1 = black and 0 = white. Row 1 is black, white, white, black. Row 2 is all white. Row 3 is white, black, black, white.
Row 1Row 2Row 3= black
(a) Write the binary for each row of the image. [3]
(b) The artist now wants to use 5 different colours. State the minimum colour depth needed and explain why. [2]

Show the model answerHide the model answer
(a) Row 1: 1001 (1), Row 2: 0000 (1), Row 3: 0110
(1)
(b) 3 bits (1). 2 bits give only 22 = 4 colours, but 3 bits give 23 = 8 colours, which is enough
(1).

Explain the effect of changing resolution or colour depth

2 to 4 marksGrade 6
  1. Say what changes: the number of pixels, or the number of bits per pixel.
  2. Explain the effect on quality: detail and sharpness, or accuracy of colours.
  3. Explain the effect on file size, using the numbers if they are given.

Example. A photographer reduces the colour depth of a photo from 24 bits to 8 bits. The resolution stays the same. Explain the effect on the image and on its file size. [4]

Show the model answerHide the model answer
Fewer colours are available: 256 instead of about 16.7 million (1), so the colours are less accurate and smooth shading may show visible bands (1). Each pixel is stored using 8 bits instead of 24 bits (1), so the file size becomes a third of the original (1).

Calculate the file size of an image

2 to 3 marksGrade 7
  1. Write the formula: colour depth × width × height.
  2. Multiply to get bits, doing the easiest multiplication first.
  3. Divide by 8 for bytes, then by 1000 for KB if asked.
  4. Write the unit at each step.

Example. An image is 400 pixels wide and 250 pixels high, with a colour depth of 8 bits. Calculate the file size in kilobytes. Use 1 KB = 1000 bytes. Show your working. [3]

Show the model answerHide the model answer
400 × 250 × 8 = 800,000 bits
(1)
800,000 ÷ 8 = 100,000 bytes
(1)
100,000 ÷ 1000 = 100 KB
(1)

Don’t lose marks

  • Saying colour depth is 'the number of colours'. It is the number of bits per pixel.
  • Saying resolution is 'the quality of the image'. It is the number of pixels.
  • Forgetting to divide by 8 to change bits into bytes.
  • Rounding the number of bits down: 5 colours need 3 bits, not 2.
  • Mixing up the two effects: resolution changes the amount of detail; colour depth changes how many colours can be shown.

More tips

Memory tricks

  • With a colour depth of 8 bits, the number of bytes equals the number of pixels (8 bits = 1 byte per pixel).
  • Colours from bits: keep doubling from 2: 1 bit → 2, 2 bits → 4, 3 bits → 8, 4 bits → 16.
  • Bits from colours: find the smallest power of 2 that is at least the number of colours: 5 colours → 8 → 3 bits.
  • Ratios save time: half the width and half the height gives a quarter of the file size.

Exam technique

  • Link cause and both effects: more pixels, so more detail AND a larger file.
  • Write the formula before substituting the numbers: it earns method marks.
  • Multiply in an easy order without a calculator: 400 × 250 = 100,000 first, then × 8.

What each grade needs

What you need to be able to do, from the first marks up to the top grade.

  1. Grade 3
    Define pixel, colour depth and resolutionA pixel is a single dot of colour; colour depth is the number of bits per pixel; resolution is the number of pixels.
  2. Grade 4
    Represent a simple image in binaryWith 1 bit per pixel, e.g. 1 = black and 0 = white, each row of pixels becomes a row of bits.
  3. Grade 5
    Explain what metadata is and why it's neededData about the image, such as width, height and colour depth, so the computer can display it correctly.
  4. Grade 5
    Work out colours from colour depthn bits per pixel give 2n colours, e.g. 3 bits give 8 colours.
  5. Grade 6
    Explain effects of resolution and colour depthIncreasing either improves the quality of the image but increases the file size.
  6. Grade 7
    Calculate an image's file sizeColour depth × width × height gives the size in bits; divide by 8 for bytes.
  7. Grade 8
    Compare file sizes after changesUse ratios, e.g. halving the width and height leaves a quarter of the pixels and a quarter of the file size.

Quick recall

Cover the answers and test yourself. The app has these as flashcards that come back just before you'd forget them.

An image is 4 pixels wide and 5 pixels high, with a colour depth of 2 bits. Calculate the file size of the image in bits.
40 bits
State how many different colours can be represented using 1 bit.
2
State the unit in which colour depth is measured.
Bits (per pixel)
An image file stores data about the image, such as its width, height and the date it was created, as well as the colours of the pixels. State the name given to this extra data.
Metadata
Complete the sentences. Use words from this list: binary, pixels, hertz, characters.
A bitmap image is made up of a grid of …………………… .
The colour of each one is stored as a …………………… number.
pixels; binary
The resolution of an image is the number of pixels it contains.
True

Sample questions

Written for this site in the style of OCR exam questions. They are not taken from real past papers.

Question 1Easy3 marks
(a) State what is meant by a pixel.
[1]
(b) State what is meant by colour depth.
[1]
(c) State what is meant by the resolution of an image.
[1]
Show the answer and mark scheme
(a)
  • a single point / the smallest element of colour in an image
(b)
  • the number of bits used to store the colour of each pixel
(c)
  • the number of pixels in the image (width × height) / the number of pixels per inch
Question 2Medium4 marks
(a) Explain what metadata is and why it is stored with an image file.
[2]
(b) Give two examples of metadata, other than width and height, that could be stored with a digital photo.
[2]
Show the answer and mark scheme
(a)
  • data about the image, e.g. its width, height and colour depth
  • so the computer knows how to display / reconstruct the image correctly, e.g. how many pixels are in each row and how many bits each pixel uses
(b)
  • colour depth
  • date / time taken
  • location / GPS coordinates
  • camera make / model / settings
  • file type / format
  • file size
  • author / copyright information
Question 3Hard5 marks
An image uses a colour depth of 2 bits, with this key: 00 = white, 01 = light grey, 10 = dark grey, 11 = black.
The image is 6 pixels wide and 6 pixels high. The first row of the image is stored as:
00 01 11 11 10 00
(a) State the colour of each pixel in the first row, from left to right.
[2]
(b) Calculate the file size of the whole image in bits. Ignore any metadata.
[1]
(c) The artist wants to use two more colours, making six colours in total. Explain the effect on the colour depth and on the file size.
[2]
Show the answer and mark scheme
(a) Answer: white, light grey, black, black, dark grey, white
  • first three: white, light grey, black
  • last three: black, dark grey, white
(b) Answer: 72 bits
  • 6 × 6 × 2 = 72 (bits)
(c)
  • the colour depth must increase to 3 bits (2 bits only gives 4 colours)
  • the file size increases by 50% / to 108 bits

More in Data storage

Stuck? Get 1-to-1 help.

Chhetri Academy tutors GCSE and A level Maths and Science online, with a free 30-minute trial lesson.