FixTheRobot Explore Robotics / Perception / P2 / P2-L2

This lab works on phones, but writing code is much easier on a laptop.

Perception · Image Processing for Robotics · P2-L2 · Beginner

Tune Thresholds Under Changing Lighting

A robot finds dark parts on a light conveyor belt. It works in the afternoon. In the morning, and when a cloud passes, it sees parts everywhere.

You will see why a fixed number cannot work, make the detector follow the overall light, and then make it follow light that changes across the image.

Your task

    Simulation
    solution.pyLoading Python…
    Ctrl+Enter runs
    What Python can I use?

    Plain Python with math (and slamkit for small matrix helpers: matmul, transpose, solve, inverse, identity). Images, point clouds and detections arrive as lists inside the dictionary D; an image is a list of rows, each row a list of pixels. There is no NumPy or OpenCV: you write the algorithm yourself, which is the point of the lab. Print with print().

    Hints

    What this lab teaches

    Stage 1 is a controlled experiment with two light levels. Stage 2 asks you to write a global normalisation. Stage 3 asks you to write a local adaptive threshold. Each is graded on hidden images with different light levels and gradients; the simulator keeps the true object positions private.

    Theory for this lab

    Image Processing for Robotics labs

    1. P2-L1: Detect Colored Objects in an Image
    2. P2-L2: Tune Thresholds Under Changing Lighting: this lab.
    3. P2-L3: Diagnose a Failing Image-Processing Pipeline

    Educational simplification: simulated 40 by 28 grey images of dark rectangles on a light floor, scaled by a light level, with an optional left-to-right shading gradient and Gaussian pixel noise. Real lighting also produces shadows with hard edges, highlights and colour casts. All images in this lab are simulated.

    Get the next lab

    Get notified when new robotics labs are released. One email per new lab, nothing else.