Worked example · Computer Science · Year 7

Turning a pixel icon into numbers

LNF: Numeracy → Developing mathematical proficiency → Conceptual understanding

What this is

A complete, secure Year 7 answer, annotated so you can see which success criterion each part meets. It is also the answer key. Headline answers: Icon A is a house with a door; Icon B is a heart; Icon C uses 32 bits; file sizes are 8, 16, 32 and 64 bytes; Icon B takes 36 characters in run-length code. The most common mistakes are forgetting that a colour pixel needs 2 bits, and thinking that doubling the width and height doubles the size.

Step 1: warm-up

QuestionAnswer
Pixels in 8 by 8 and 16 by 1664 and 256
Bits in a byte8
Colours with 1, 2 and 3 bits2, 4 and 8

Step 2: bits to picture

□□□■■□□□
□□■■■■□□
□■■■■■■□
■■■■■■■■
□■□□□□■□
□■□■■□■□
□■□■■□■□
□■■■■■■□

The picture is a house with a pointed roof, walls and a door in the middle.

The pupil moves from one representation (bits) to another (a picture). Evidences criterion 1.

Step 3: picture to bits

RowBitsRowBits
100000000501111110
201100110600111100
311111111700011000
411111111800000000

Every row has exactly 8 bits, one for each pixel. Evidences criterion 1.

Step 4: a colour icon

WYYW
YOOY
WYYW
GGGG

A yellow flower with an orange centre, above green grass.

(b) 16 pixels × 2 bits = 32 bits (4 bytes). It is not 16 because each pixel needs 2 bits to choose one of 4 colours, not 1 bit.

The pupil splits each row into pairs before decoding, and links the number of bits to the number of colours. Evidences criteria 1 and 3.

Step 5: how much space?

IconPixelsBits per pixelBitsBytes
8 by 8, 2 colours641648
8 by 8, 4 colours64212816
8 by 8, 16 colours64425632
16 by 16, 4 colours256251264

(b) No. Doubling the width and the height makes 2 × 2 = 4 times as many pixels (64 becomes 256). With 4 colours the size goes from 16 bytes to 64 bytes, which is 4 times as big, not twice.

(c) 1 bit can only be 0 or 1, so it can only show 2 colours: 3 colours is a non-example. She needs 2 bits per pixel, which gives 4 codes, so one code is spare.

The pupil connects pixels to area and uses the table to test Harri’s claim, instead of just agreeing. Nia’s idea is used as a non-example. Evidences criteria 2 to 5.

Step 6: run-length encoding

RowRunsCharactersRowRuns and characters
18W251W6B1W, 6
21W2B2W2B1W1062W4B2W, 6
38B273W2B3W, 6
48B288W, 2

(b) Total: 2 + 10 + 2 + 2 + 6 + 6 + 6 + 2 = 36 characters compared with 64 bits. Row 2 is longer (10 characters instead of 8), because its colour changes 4 times, so there are 5 short runs. Run-length code only saves space when there are long runs of the same colour.

The pupil checks each run adds up to 8 pixels, and explains when the method does not help. Evidences criteria 1 and 5.

If you finish early: answers

Why this response is secure