← ACARA Digital Technologies Years 5–6

Encoding a picture with a colour key

A list that says which number stands for which colour. To encode a picture, write each pixel's colour number in a grid, row by row, for a partner to decode.

Understanding Encoding a picture with a colour key in ACARA Digital Technologies Years 5–6

What it does: Encoding means turning a colour into its number using the colour key, one pixel at a time. Each row of numbers matches one row of pixels, so a partner can decode the grid by using the same key. The colour key says 1 stands for red, so you write 1 for every red pixel. Go left to right and swap each colour for its number: white 0, green 1, green 1, white 0. A colour key only works if every colour has a different number, such as 1 = red and 2 = blue.

Common mistakes: The colour key says 1 stands for red and 2 stands for blue. A red pixel must be written as 1, not 2. The key is swapped. The code 1 0 1 for black white black only works if 1=black and 0=white, so the key must be 0=white 1=black.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 59–71) and word search (Modules 44–71).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
You have a colour key: 0 = white, 1 = red, 2 = blue. A pixel is red. Which number do you write in the grid?
21
Matches
Key: 1 = red, 1 = blue
↓
Two colours share the same number, so a partner cannot tell if a 1 means red or blue. Each colour needs its own number.
Applying
Meanings
Term
colour key
Meaning
A list that says which number stands for which colour. To encode a picture, write each pixel's colour number in a grid, row by row, for a partner to decode.
Practice
Key: 0=white 1=red 2=blue
Testing
Gaps
Pixel number:
Check Answer
Spots
1key: 0=white 1=red 2=blue
2pixel 1 is red, so write 2

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Nautilus' badge — Default Expert, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. You have a colour key: 0 = white, 1 = red, 2 = blue. A pixel is red. Which number do you write in the grid?
A. 2
B. 1 ✓
The colour key says 1 stands for red, so you write 1 for every red pixel.
2. Which tells you how to encode a pixel picture with a colour key?
A. Write the colour number for each pixel in a grid, row by row ✓
B. Write the colour names in a list in any order
Encoding means turning each pixel's colour into its number and writing the numbers in a grid, one row at a time, so a partner can decode it.
3. Why do you give your partner the colour key along with your number grid?
A. So they know which colour each number stands for ✓
B. So they can see how many pixels are in the picture
Without the key, the numbers are just numbers. The key lets your partner decode them back into colours.
4. Your pixel art on squared paper has 4 rows. How many rows will your number grid have?
A. 1 row
B. 4 rows ✓
Each row of squares becomes one row of numbers, so the grid has the same shape as the picture.
5. Key: 0 = white, 1 = green. The top row of squares is white, green, green, white. Which row of numbers is correct?
A. 0 1 1 0 ✓
B. 1 0 0 1
Go left to right and swap each colour for its number: white 0, green 1, green 1, white 0.

Match the Pairs

1 = red, 2 = blue, 3 = green → A colour key that says which number stands for which colour
2 2 1 3 → One row of a number grid: the colour numbers of four pixels, read from left to right
To encode a pixel, look up its colour in the key and write that colour's number → Key: 1 = yellow. Pixel is yellow, so write 1
Write the numbers row by row, so the grid of numbers has the same shape as the picture → 1 2 1 2 1 2 1 2 1
Key: 1 = red, 1 = blue → Two colours share the same number, so a partner cannot tell if a 1 means red or blue. Each colour needs its own number.
Picture row: red, blue, red Grid row: 1 2 → The grid row has only two numbers for three pixels. Every pixel needs its own number, so the row should be 1 2 1.

Key Term

colour key
A list that says which number stands for which colour. To encode a picture, write each pixel's colour number in a grid, row by row, for a partner to decode.

Fill in the Blanks

1. Key: 1 = red, 2 = blue Pixel colour: blue Pixel number: 2
Hint: Look at the colour key and type the number that stands for blue.
2. Key: 0 = white, 1 = black, 2 = grey Row 1: black white grey Row 1: 1 0 2
Hint: Use the colour key to type the number for the last pixel, grey.
3. Key: 1 = red, 2 = blue, 3 = green
Hint: Type the word for the list that says which number stands for which colour.
4. Key: 1 = red, 2 = blue Row 1: 2 1 1 Row 1 colours: blue red red
Hint: Decode the last number in the row by looking it up in the colour key. Type the colour word.
5. Pixel art: 4 across, 3 down Write the numbers row by row Each row has 4 numbers
Hint: Type how many numbers fit in one row, matching the pixels across.

Spot the Error

Question 1
A key: 0=white 1=red 2=blue
B pixel 1 is red, so write 2
C pixel 2 is white, so write 0
D pixel 3 is blue, so write 2
Line B — The colour key says 1 stands for red and 2 stands for blue. A red pixel must be written as 1, not 2.
Question 2
A key: 0=black 1=white
B row 1: black white black
C row 1 code: 1 0 1
Line A — The key is swapped. The code 1 0 1 for black white black only works if 1=black and 0=white, so the key must be 0=white 1=black.
Question 3
A key: 1=red 2=green 3=blue
B row 1: green blue red = 2 1 3
C row 2: red red blue = 1 1 3
Line B — Green is 2, blue is 3 and red is 1 in the key. So green blue red must be written 2 3 1, not 2 1 3.
Question 4
A key: 0=white 1=blue
B row 1: 0 1 0
C row 2: 1 1 1
D row 3: 0 3 0
Line D — The key only has the numbers 0 and 1. The number 3 is not in the key, so no colour matches it. Row 3 should be 0 1 0.
Question 5
A FOR each row of the picture
B FOR each pixel in the row
C WRITE its colour name
D START a new line
Line C — An encoded grid holds numbers, not words. Use the colour key to write the pixel's colour number.

Student with a class code? Join your class →