The answersDownload the PDF
Worksheet

U11.5 Colour, and why it breaks

Vision · University · about 35 min

BugBotLab
NameClassDate

What this lesson is about

Segmentation by threshold, what the threshold is really measuring, and where it fails.

Questions 6 marks in all

  1. [1 mark]Why does the test r > 150 fail to find a red ball on the nearly white mat, even in a simulator with no lighting model?

    1. AIt tests brightness, and white is red-rich, so the mat passes too
    2. BThe simulator's red is below 150
    3. CThe camera's white balance shifts the ball towards grey
    4. DThe threshold should be in radians
  2. [1 mark]Four pixels: white mat, a red ball, the same ball in shadow, and a pale pink wall. What does this print?

    pixels = [(230, 225, 220), (200, 40, 30), (120, 30, 25), (240, 200, 180)]
    bright = sum(1 for (r, g, b) in pixels if r > 150)
    dominant = sum(1 for (r, g, b) in pixels if r - max(g, b) > 60)
    chroma = sum(1 for (r, g, b) in pixels if r / (r + g + b + 1) > 0.5)
    print(bright, dominant, chroma)
  3. [1 mark]In a 64 pixel wide picture from the 320 pixel camera, the red pixels' centroid is at column 40. What is the bearing in degrees to 1 decimal place, using f = 92.4?

  4. [1 mark]In pixel = illumination x reflectance x sensor response, which factor is a property of the object?

    1. AReflectance
    2. BIllumination
    3. CSensor response
    4. DAll three
  5. [1 mark]Which of these break a colour threshold that worked in the lab?

    Tick every answer that is true.

    1. AAuto exposure changing the gain when a dark object fills the view
    2. BAuto white balance shifting the channels
    3. CA shadow or a specular highlight across the object
    4. DDifferent light, such as fluorescent instead of daylight
    5. EConverting the column to a bearing with the pinhole model
  6. [1 mark]Why is a specular highlight worse for a chromaticity test than a shadow?

    1. AA highlight saturates the channels, and a clipped channel has thrown its information away for good
    2. BA shadow is darker, so it is easier to threshold
    3. CChromaticity divides by brightness, which is zero in a highlight
    4. DHighlights only affect the red channel

The task: threshold a picture

A red ball is ahead of the robot. Take a 64 by 48 picture with camera_image(64, 48) and print three things: naive:, the percentage of the picture that passes a plain r > 150 test; red:, how many pixels pass a test that looks at colour rather than brightness; and bearing:, the bearing in degrees of the centroid of those pixels.

from bugbot import *
import math
connect()

F = 92.4
W, H = 64, 48
img = camera_image(W, H)

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

QR code
Do it on the robot
www.bugbotlab.com/learn/u11-5-colour-and-light/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Compare your bearing with the one the built-in blob detector reports. How close, and which would you trust?
  2. Redo the mask in normalised chromaticity, r / (r + g + b), and find the threshold that separates the ball from the mat. How wide is the gap between the two populations?
  3. Count how many pixels the ball covers, and use that area to estimate its range as in U11.3. Compare with the detector.