The answersDownload the PDF
Worksheet

F8.10 Project: send a picture

Data representation · GCSE · about 25 min

BugBotLab
NameClassDate

What this lesson is about

Capture a camera frame, make it 1-bit, compress it with RLE and send it by radio.

Questions 4 marks in all

  1. [1 mark]A 32 × 24 image at 1 bit per pixel. How many bits uncompressed?

  2. [1 mark]Why are the RLE rows joined with /?

    1. ASo the receiver knows where each row ends
    2. BTo make the message shorter
    3. CBecause RLE requires it
    4. DTo encrypt the picture
  3. [1 mark]How does the program prove the compression was lossless?

    1. AIt decodes the message and checks the rows equal the original picture
    2. BIt checks the message is under 200 characters
    3. CIt counts the # characters
    4. DIt sends the message twice
  4. [1 mark]Why does a busier picture make a longer message?

    1. AIt has shorter runs, so RLE saves less
    2. BIt has more pixels
    3. CBusy pictures use more colours in 1-bit
    4. DThe radio slows down

The task: send a picture

Build the program from the brief. Print the 24 picture lines, then uncompressed: 768 bits (calculated), compressed: <n> characters, and lossless: True. Send the message if it has 200 characters or fewer.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

img = camera_image(32, 24)

Plan your program here, then type it in and press Run.

QR code
Do it on the robot
www.bugbotlab.com/learn/f8-10-project-send-a-picture/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Compress the whole picture as one string instead of row by row. Which is shorter, and why?
  2. Send a 64 × 48 picture by splitting its message into several messages of 200 characters each, numbered so they can be put back in order.
  3. Invent a way to make the message shorter still, for example by writing a row that repeats the one above it as =.