Computer Science • Data Representation

Pixel Painter

8 × 8, 2 colours

Encode each row of the target image as runs: a count, then a colour. WWWBBBBW is 3W 4B 1W.

A wrong row costs 5 seconds; finishing rows and images adds time. Choose the grid size and colours above.

Pixel Painter — Explanation

Run-length encoding (RLE) is a lossless way of compressing data that has long runs of the same value, such as simple images. Instead of storing every pixel, it stores each run: how many pixels in a row are the same colour, then the colour.

Example: the row WWWBBBBW (3 white, 4 black, 1 white) is stored as 3W 4B 1W: three runs instead of eight pixels. The image can be rebuilt exactly from the runs, so nothing is lost. But each run is two values (a count and a colour), so RLE only saves space when the runs are long: a busy image, where the colour changes often, can need more values than it has pixels.

How to play

You start with 60 seconds. Each row and each image you finish adds time (up to 60), and more points in the bigger and more colourful modes. The clock runs 3% faster for every row you've finished, so it gets harder as you go. The game ends when the time runs out.

Objective: explain how run-length encoding compresses an image without losing data, and encode an image as runs of a count and a colour (for example, Cambridge IGCSE Computer Science 0478, 1.3 data storage and compression; Cambridge International AS & A Level 9618, 1.3 compression).

Where this fits

  • AP: AP Computer Science Principles
  • AQA: AQA A Level Computer Science (7517)
  • Cambridge: Cambridge IGCSE Computer Science (0478); Cambridge A Level Computer Science (9618); Cambridge AS Level Computer Science (9618)
  • IB: IB Computer Science HL; IB Computer Science SL
  • Pearson Edexcel International: Edexcel International GCSE Computer Science (4CP0)
  • USDP: USDP Computer Science

Pixel Painter — Key Terms

Key concepts in English, with te reo Māori, Chinese (Simplified) and Korean.

EnglishTe reo Māori中文(简体)한국어What it means on this page
Run-Length Encoding (RLE)no attested term游程编码 / 行程编码런 렝스 부호화A simple lossless compression algorithm that replaces consecutive repeated data units with a single count and value.
Lossless Compressionno attested term无损压缩무손실 압축A data compression method where the original data can be perfectly reconstructed without losing any quality.
Runno attested term游程 / 连续长런 (연속 데이터)A sequence of adjacent, identical data elements (e.g. 5 consecutive white pixels).
Compression Rationo attested term压缩比압축률The ratio comparing the uncompressed data size against the compressed data size.
Pixelpika像素픽셀(화소)The smallest individual controllable dot of colour making up a digital image grid.
Raster Graphicno attested term位图 / 栅格图像래스터 그래픽A grid-based digital image made up of a matrix of individual pixel values.

On the te reo Māori column. Terms marked as gaps have no attested equivalent in the sources checked — Karaitiana Taiuru's Dictionary of Māori Computer and Social Media Terms, Paekupu, the Reserve Bank's te reo financial glossary, NZQA and Te Aka. No coinage is printed as though it were established; where a class needs one, commission it from Te Taura Whiri i te Reo Māori and credit the translator. Te reo Māori is not italicised and takes no plural "s".