SLIDE 1
CSZone.co.uk
Click to reveal · Arrow keys also work
OCR J277 · Component 1 · Topic 1.2.4f

Images in Binary

Pixels & Bitmaps · Colour Depth · Resolution · Metadata · Calculating File Size · Exam Practice

CSZone OCR GCSE Computer Science J277
Learning Objectives

By the end of this video you will be able to...

Explain how an image is represented as a series of pixels, each with a specific colour represented by a binary code
Define colour depth and explain its effect on the number of colours available, image quality and file size
Define resolution and explain its effect on image quality and file size
Explain what metadata is and why an image file needs it
Calculate the file size of a bitmap image given its colour depth and resolution
⚡ Builds directly on 1.2.4e — the "more bits = more options" rule applies to colours too
Pixels & Bitmaps

An image is a grid of pixels

KEY IDEA
A bitmap image is represented as a series of pixels (picture elements). Each pixel has a specific colour, represented by a specific binary code.
Zoom in far enough on any digital photo and you'll see these individual coloured squares — each one stored as binary in the file.
⚡ The whole image file is just a long list of pixel colour codes, one after another — plus some extra information about the image itself (metadata).
Colour Depth

Colour depth — bits per pixel

DEFINITION
Colour depth is the number of bits used to represent the colour of each pixel.
The same rule from 1.2.4e applies: with n bits, you can represent 2ⁿ different colours.
Colour DepthCalculationColours Possible
1 bit2 (black/white)
2 bits4
8 bits2⁸256
⚡ More bits per pixel = more possible colours = a more realistic-looking image — but larger file size.
Resolution

Resolution — how many pixels?

DEFINITION
Resolution is the number of pixels that make up an image, usually given as width × height.
ResolutionCalculationTotal Pixels
100 × 100100 × 10010,000
Each one of those 10,000 pixels needs its own colour code stored — so the total number of pixels directly affects how much data the image contains.
⚡ Higher resolution = more pixels = more detail — but also a larger file size.
Quality & File Size

The effect of colour depth and resolution

RESOLUTION ↑
More pixels means finer detail and a sharper image — but also a larger file size, because there are more pixels to store.
COLOUR DEPTH ↑
More bits per pixel means more possible colours and more realistic shading — but also a larger file size, because each pixel needs more bits stored.
Reducing either resolution or colour depth has the opposite effect: smaller file size, but lower quality.
⚡ Exam phrasing: "Increasing the resolution/colour depth increases the quality of the image, but also increases the file size."
File Size

Calculating image file size

FORMULA
image file size = colour depth × height (px) × width (px)
colour depth (bits per pixel) × height (in pixels) × width (in pixels).
Height × width gives the total number of pixels. Multiplying by the colour depth gives the total number of bits needed to store all of them.
⚡ The formula gives the answer in bits. Divide by 8 to convert to bytes, then divide by 1,000 for KB, etc.
Worked Example

Calculating a file size

Exam-style question
An image has a resolution of 100 × 100 pixels and a colour depth of 8 bits. Calculate the file size of the image in bytes.
file size = colour depth × height × width
file size = 8 × 100 × 100
file size = 80,000 bits
bytes = bits ÷ 8
bytes = 80,000 ÷ 8
bytes = 10,000 bytes
ANSWER
The file size is 10,000 bytes — or 10 KB (using 1,000 bytes per KB).
Metadata

Metadata — data about the data

DEFINITION
Metadata stores additional information about the image, e.g. its height, width, and colour depth.
Without metadata, the computer wouldn't know how to arrange the long list of pixel codes back into a 2D image — it needs to know the width and height to know where each row ends.
It also needs the colour depth, so it knows how many bits to read for each pixel's colour code.
⚡ Metadata is stored as part of the image file, so it adds a small amount to the overall file size too.
Exam Practice

Exam-Style Questions

Question 1 · 1 mark
State what is meant by the term "metadata" in relation to an image file.
1 mark
ANS
Metadata is data about the image file, e.g. its height, width and colour depth — used by software to display the image correctly.
Question 2 · 2 marks
An image uses a colour depth of 2 bits. State the maximum number of colours each pixel can have, showing your working.
2 marks
ANS
2² = 4 colours
Question 3 · 3 marks
An image has a resolution of 200 × 50 pixels and a colour depth of 4 bits. Calculate the file size of the image in bytes.
3 marks
ANS
4 × 200 × 50 = 40,000 bits ÷ 8 = 5,000 bytes
Common Mistakes

Four mistakes that cost marks

1
Forgetting to divide by 8. The file size formula gives an answer in bits. If the question asks for bytes, KB or MB, you must divide by 8 first.
2
Mixing up resolution and colour depth. Resolution is about how many pixels (width × height). Colour depth is about how many bits per pixel. They are different things — both affect file size.
3
Saying "more colour depth = more pixels." It doesn't. Colour depth only changes how many colours each existing pixel can be — it does not add or remove pixels.
4
Forgetting metadata exists. The file size formula calculates the pixel data only — the actual file on disk will be slightly larger because it also stores metadata.
Summary

1.2.4f — Images in Binary

PIXELS
An image is a grid of pixels. Each pixel's colour is stored as a binary code.
COLOUR DEPTH
Bits per pixel. n bits = 2ⁿ colours. More bits = more colours, larger file.
RESOLUTION
Width × height in pixels. More pixels = more detail, larger file.
METADATA
Extra info (height, width, colour depth) stored with the image so it can be displayed correctly.
⚡ Exam formula: file size (bits) = colour depth × image height (px) × image width (px). Divide by 8 for bytes.
CSZone.co.uk

That's 1.2.4f done.

Next up: 1.2.4g — Sound in Binary

Full quiz, marked worksheet and slides at CSZone.co.uk