Each project below is tailored to a specific algorithm and scientific question from Chapter 19, with concrete inputs, verifiable numerical outputs, boundary cases, and links to the related lab and pioneer.
Project 1 of 3 · v1-c19-p01Intermediate · ~30 min
3×3 Sobel Edge-Detection Convolution Lab
Lab activity: 1. Find the edges · Related code: block-01.js, block-04.js · Pioneer: View profile
Real-World Problem: Self-driving cars and document scanners must locate object boundaries inside raw pixel arrays.
Scientific Question: Why does a 3×3 convolution kernel with balanced positive and negative weights vanish on flat surfaces and peak at edges?
Objective: Apply horizontal and vertical 3×3 edge kernels to a synthetic grayscale grid and compute edge magnitude.
Hypothesis to Test: Applying kernel [[-1,0,1],[-2,0,2],[-1,0,1]] outputs 0 on solid patches and strong responses along vertical dark-to-light transitions.
Step-by-Step Implementation
Represent an 8×8 grayscale image as a 2D array of integers 0–255.
Slide a 3×3 vertical Sobel kernel over interior pixels (1..6, 1..6) computing weighted sums.
Repeat with a horizontal Sobel kernel and combine via sqrt(Gx^2 + Gy^2).
Test a completely uniform image (all 128s) and verify every output pixel is 0.
Concrete Input: 8×8 grayscale grid with a dark left half (20) and bright right half (220).
Test Cases: Uniform 128 grid -> all 0; Vertical step -> strong vertical edge, horizontal edge = 0.
Boundary Condition: Border pixels (row 0, col 0, etc.) require zero-padding, clamping, or skipping.
Common Mistake to Avoid: Overwriting the input array in-place while still reading neighboring pixels for the next cell.
Interpreting Results: Local linear filters extract edges and textures that form the first layers of both classical vision and CNNs.
Show Hint, Extension Challenge & Reflection
Hint: Review the worked example and equation in Chapter 19 before testing the boundary case: Border pixels (row 0, col 0, etc.) require zero-padding, clamping, or skipping.
Extension Challenge: Swap in a 3×3 averaging blur kernel (all 1/9) and verify it smooths out single-pixel salt-and-pepper noise.
Reflection Question: How did Paul Viola and Michael Jones's fast rectangular features enable real-time face detection on early cameras?
Hint: Review the worked example and equation in Chapter 19 before testing the boundary case: Blank 5×5 grid should output "No ink detected" rather than guessing a random digit.
Extension Challenge: Add automatic center-of-mass alignment before template matching and re-test the shifted digit.
Reflection Question: Why did Fei-Fei Li's ImageNet dataset transform computer vision as much as new algorithms did?
Test Cases: T = 0.0 -> FAR=100%, FRR=0%; T = 1.0 -> FAR=0%, FRR=100%.
Boundary Condition: If genuine and impostor distributions overlap, NO threshold can achieve 0% FAR and 0% FRR simultaneously.
Common Mistake to Avoid: Evaluating a security classifier using overall accuracy alone when impostors are rare or common.
Interpreting Results: Threshold engineering is a policy and safety decision, not purely a math constant.
Show Hint, Extension Challenge & Reflection
Hint: Review the worked example and equation in Chapter 19 before testing the boundary case: If genuine and impostor distributions overlap, NO threshold can achieve 0% FAR and 0% FRR simultaneously.
Extension Challenge: Check how performance differs if two demographic groups have slightly shifted score distributions (fairness audit).
Reflection Question: What real-world harms happen when biometric systems are deployed without measuring subgroup error rates?