The answersDownload the PDF
Worksheet

F8.7 Images

Data representation · GCSE · OCR J277 1.2.4, AQA 8525 3.3.6, Edexcel 1CP2 2.2.2 · about 15 min

BugBotLab
NameClassDate

What this lesson is about

Pixels, resolution, colour depth, metadata and file size, from the robot's camera.

Questions 5 marks in all

  1. [1 mark]An image is 32 × 24 pixels with a colour depth of 8 bits. How many bits is it?

  2. [1 mark]How many colours can a pixel with a colour depth of 4 bits have?

  3. [1 mark]Doubling both the width and height of an image does what to its file size?

    1. AMultiplies it by 4
    2. BDoubles it
    3. CLeaves it the same
    4. DHalves it
  4. [1 mark]What is metadata in an image file?

    1. AData about the image, such as its width, height and colour depth
    2. BThe brightest pixels
    3. CThe compressed pixels
    4. DA copy of the image
  5. [1 mark]What is the effect of increasing colour depth?

    1. AMore colours and a larger file
    2. BFewer pixels
    3. CA smaller file
    4. DLower resolution

The task: camera pixels

Capture camera_image(32, 24). Print it as 24 lines of 32 characters, # for a pixel whose average of red, green and blue is below 128, . otherwise. Then print 1-bit size: <bits> and 24-bit size: <bits> for a 32 × 24 image, worked out with a calculation.

# 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-7-images/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Count how many pixels in the picture are mostly red, meaning red is more than green and blue added together.
  2. Print a greyscale picture using the characters .:-=+*#%@ from light to dark.
  3. How many bytes would 10 seconds of camera frames at 320 × 240, 24-bit and 30 frames a second take?