Study Guide
Representing Images
How a computer stores a picture as a grid of pixels, each coded in binary, and how the resolution and the colour depth change the quality and the size of an image.
Lesson 1.8 Data Representation
For: Cambridge IGCSE Computer Science learners, or anyone who can already convert between binary and denary
Stage: Think
A picture over the phone
A fictional pupil, Aroha, has a small picture made by colouring squares black on squared paper. Her friend Ben has a blank sheet of the same squared paper, and they can only talk on the phone.
Think it through
How could Aroha describe the picture so that Ben can colour in exactly the same squares? What would she need to tell him first, and then for every square?
- Hint 1: Where could she start, and in which order could she go through the squares?
- Hint 2: Each square has only two possibilities. What short word, or number, could stand for each?
Show a model answer
She tells Ben how many squares wide and how many tall the picture is. Then she goes through it in order, row by row from the top, saying for each square whether it is black or white. Because there are only two possibilities, she could say 1 for black and 0 for white, which is exactly the kind of information a computer can store.
A computer stores a picture in the same way. The picture is divided into a grid of tiny squares called pixels (short for picture elements). Each pixel is one single colour, and the code for that colour is stored in binary. The computer stores the grid’s size, then the code of every pixel, row by row.
Stage: Discover
Encoding a black-and-white picture
A small picture of a house is 8 pixels wide and 6 pixels tall. Each pixel is either black or white.
Think it through
If each pixel is stored as a single bit, how many pixels are in the picture, and how many bits will the whole picture take?
- Hint 1: Think of a table with 6 rows and 8 columns.
- Hint 2: One bit for each pixel.
Here is the picture, written with # for a black pixel and . for a white one. Let 1 stand for black and 0 for white. Write each row as 8 bits.
| Row | Picture (# black, . white) | 8-bit binary |
|---|---|---|
| 1 | ...##... | 0001 1000 |
| 2 | ..####.. | |
| 3 | .######. | |
| 4 | ######## | |
| 5 | .######. | |
| 6 | .##..##. |
- Write a 1 for every # and a 0 for every . in the same order, from left to right.
Show the completed table
| Row | Picture (# black, . white) | 8-bit binary |
|---|---|---|
| 1 | ...##... | 0001 1000 |
| 2 | ..####.. | 0011 1100 |
| 3 | .######. | 0111 1110 |
| 4 | ######## | 1111 1111 |
| 5 | .######. | 0111 1110 |
| 6 | .##..##. | 0110 0110 |
The six rows take 6 × 8 = 48 bits, as you predicted. Notice that this is a table of bits only: the computer also needs to know that each row is 8 pixels wide, so that it can start a new row in the right place.
Check your understanding
Show the answer
Answer: B. #..##..# (black, two white, two black, two white, black)
Reading from the left, 1 0 0 1 1 0 0 1 is black, white, white, black, black, white, white, black.
Stage: Predict
How many pixels?
The same house can be drawn on a grid that is 8 pixels wide and 6 tall, or on one that is 16 pixels wide and 12 tall.
Think it through
The grid is doubled in width and in height, from 8 × 6 to 16 × 12. How many pixels does it have now? Which picture will have smoother edges, and which will need more bits?
- Hint 1: Work out 8 × 6, and then 16 × 12.
- Hint 2: More pixels mean each pixel is smaller.
Show what happens
The first grid has 48 pixels and the second has 16 × 12 = 192, which is four times as many, not twice: both the width and the height doubled. The bigger grid has smaller pixels, so edges look smoother, and with one bit for each pixel it needs 192 bits, four times as many bits.
The number of pixels in an image is its resolution. It can be given as the width by the height (such as 16 × 12), or as the total number of pixels (192). A higher resolution means more, smaller pixels, so more detail and a smoother picture, but also more data to store.
| Width | Height | Number of pixels |
|---|---|---|
| 4 | 4 | 16 |
| 8 | 6 | |
| 20 | 10 | |
| 100 | 50 | |
| 1000 | 500 |
- Multiply the width by the height.
Show the completed table
| Width | Height | Number of pixels |
|---|---|---|
| 4 | 4 | 16 |
| 8 | 6 | 48 |
| 20 | 10 | 200 |
| 100 | 50 | 5000 |
| 1000 | 500 | 500 000 |
Stage: Predict
More than black and white
Aroha now wants to draw a house in four colours: white, black, red and blue. One bit for each pixel is not enough.
Think it through
How many bits does each pixel need if the picture uses four different colours? Make up a code of that many bits for each colour.
- Hint 1: How many patterns do 2 bits make?
- Hint 2: Any code will do, as long as no two colours share a pattern.
Show what happens
2 bits make 2² = 4 patterns, so each pixel needs 2 bits. One possible code is 00 for white, 01 for black, 10 for red and 11 for blue. It could be any other, as long as the sender and the receiver use the same one.
The number of bits used for the colour of each pixel is the colour depth. A colour depth of n bits gives 2ⁿ different colours.
| Colour depth | Number of colours |
|---|---|
| 1 bit | 2 |
| 2 bits | |
| 3 bits | |
| 8 bits | |
| 24 bits |
- n bits make 2ⁿ patterns, so each extra bit doubles the number of colours.
Show the completed table
| Colour depth | Number of colours |
|---|---|
| 1 bit | 2 |
| 2 bits | 4 |
| 3 bits | 8 |
| 8 bits | 256 |
| 24 bits | 16 777 216 |
Using the code 00 white, 01 black, 10 red and 11 blue, a row of 6 pixels is black, red, red, blue, white, black.
| Pixel | Colour | 2-bit code |
|---|---|---|
| 1 | black | 01 |
| 2 | red | |
| 3 | 10 | |
| 4 | blue | |
| 5 | 00 | |
| 6 | black |
- The code is 00 white, 01 black, 10 red and 11 blue.
Show the completed table
| Pixel | Colour | 2-bit code |
|---|---|---|
| 1 | black | 01 |
| 2 | red | 10 |
| 3 | red | 10 |
| 4 | blue | 11 |
| 5 | white | 00 |
| 6 | black | 01 |
The row is stored as 01 10 10 11 00 01: 12 bits for 6 pixels, which is 6 × 2.
Check your understanding
Show the answer
Answer: C. 3 bits, because 2³ = 8 and that is at least five colours.
2² = 4 is too few, and 2³ = 8 is enough, so the smallest colour depth is 3 bits. Three of the eight patterns are left unused.
Stage: Explain
Two settings that get mixed up
Think it through
One fictional photo looks blocky: you can see square steps along every edge. Another has smooth edges, but its sky is made of a few flat bands of blue instead of a smooth change. For each photo, say which setting is too low, the number of pixels or the number of bits for each pixel.
- Hint 1: Which setting controls the size of the squares?
- Hint 2: Which setting controls how many different blues are possible?
Show a model answer
The blocky photo has too few pixels: its resolution is too low, so each pixel is large. The photo with bands of blue has too few colours to choose from: its colour depth is too low, so a smooth change has to be rounded to a few steps.
Do not confuse: Resolution and colour depth
- How many pixels?Image resolution
- The number of pixels in the image, such as 16 × 12 = 192.A higher resolution gives smaller pixels and a sharper picture.
- How many bits for each pixel?Colour depth
- The number of bits used for the colour of each pixel, which sets how many colours are possible.A higher colour depth gives more colours and smoother changes of colour.
Raising either one improves the quality of the image and makes the file bigger.
The number of pixels and the number of colours are separate. A picture with a very high resolution can still use only two colours, if each pixel has 1 bit. A picture with only a few pixels can have millions of colours, if each pixel has 24 bits. Resolution says how many pixels; colour depth says how many colours each pixel can be.
Each version is worked out as pixels × bits for each pixel.
- Black and white, 8 × 6. 48 pixels × 1 bit = 48 bits.
- Black and white, 16 × 12. 192 pixels × 1 bit = 192 bits: four times as many, because there are four times as many pixels.
- Four colours, 8 × 6. 48 pixels × 2 bits = 96 bits: twice as many, because each pixel has twice as many bits.
- Four colours, 16 × 12. 192 pixels × 2 bits = 384 bits: eight times the first version, since it has four times the pixels and twice the bits.
Each increase improves the picture and enlarges the file. The next lesson turns this working into a rule.
Stage: Apply
Choose settings for a job
Apply it
Show the answer
Answer: B. Use a photo with a higher resolution, at the cost of a bigger file.
The blocks are the pixels, so the photo needs more of them: a higher resolution. The cost is a bigger file.
Apply it
Show the answer
Answer: A. The colour depth, because too few colours are available for a smooth change.
Bands show that colours are missing, not pixels. The colour depth is too low, so a smooth change is rounded to a few steps.
Apply it
Show the answer
Answer: C. Picture P, because 100 × 100 × 8 = 80 000 bits and 50 × 50 × 24 = 60 000 bits.
P: 10 000 pixels × 8 bits = 80 000 bits. Q: 2500 pixels × 24 bits = 60 000 bits. Both settings matter, and neither one alone decides the size.
Go deeper Beyond the specification: file headers and vector graphics
An image file is not only a list of pixel codes. A bitmap file starts with a file header that stores information such as the image’s width, its height and its colour depth, so that a program knows how to read the pixels that follow. The image’s resolution is a property of the file. It is different from the screen resolution, which is the number of pixels a display can show.
A bitmap image stores a code for every pixel. A vector graphic stores shapes instead: a drawing list of drawing objects, each with properties such as its position, size and colour. A tiny example, not a real file format:
rectangle x=10 y=10 width=80 height=40 fill=blue
circle x=50 y=30 radius=15 fill=yellowBecause the shapes are described, a vector graphic can be drawn at any size without blocky edges, and the list can be short for a simple logo. A photograph has too much detail to describe in shapes, so it is stored as a bitmap. The specification for IGCSE asks only for bitmap images.
Stage: Consolidate
Bring it together
Think it through
Without looking back, explain to a friend how a computer stores a picture, and what image resolution and colour depth each mean.
Show a model answer
The picture is a grid of pixels. Each pixel is one colour, stored as a binary code, and the codes are stored row by row. The resolution is the number of pixels (width × height). The colour depth is the number of bits used for each pixel’s colour, so n bits give 2ⁿ colours.
Check your understanding
Show the answer
Answer: A. 16, because 2⁴ = 16.
2 × 2 × 2 × 2 = 16 colours.
- A computer stores an image as a grid of pixels. Each pixel has one colour, stored as a binary code, and the codes are kept row by row.
- The image resolution is the number of pixels, written as width × height. Doubling both width and height gives four times as many pixels.
- The colour depth is the number of bits for the colour of each pixel. With n bits there are 2ⁿ colours: 1 bit gives 2, 8 bits give 256 and 24 bits give 16 777 216.
- A higher resolution and a higher colour depth both improve quality and make the file bigger. They are separate settings: more pixels do not mean more colours.
- Blocky edges point to too low a resolution. Flat bands of colour point to too low a colour depth.
Sources and scope
- What this lesson is. The eighth lesson of the Data Representation module, written for this site. It teaches point 3 of Cambridge IGCSE Computer Science 1.2 (images, resolution and colour depth) against the 2026 to 2028 syllabus (version 6). Its curriculum links are provisional: no link has been verified by the site owner. They show where the lesson may help with a course and imply no review or endorsement by any examination board.
- Original material. Aroha and Ben, the pixel house, the four-colour code, the club logo, the poster, the sunset photo and the two stored pictures are fictional examples written for this lesson. The colour codes are made up to practise decoding, and are not a real standard.
- Simplified on purpose. Colours are treated as codes in a list; how a 24-bit colour is made from red, green and blue is not taught. The calculation of a file size, in bytes and larger units, is in the next lesson. File headers, vector graphics and screen resolution appear only in the optional extension.
The number system with only two digits, 0 and 1, in which each column is worth twice the column to its right.
A single binary digit: 0 or 1. The smallest unit of data a computer stores.
A group of eight bits, which can hold one of 256 different patterns.
The number of bits used to store the colour of each pixel, so that n bits give 2ⁿ possible colours.
The number of pixels in an image, often written as its width by its height.
One of the tiny squares that make up an image, each of which has a single colour stored as a binary code.
Your progress on this lesson
Saved in this browser only. It is not sent anywhere, does not follow you to another device, and is lost if you clear this site’s data.
This browser is not allowing the site to save progress, so it will be forgotten when you leave the page.