A modern approach to AI · Chapter 25

Computer Vision

Vision systems infer useful properties of a scene from images, from local edges and object categories to three-dimensional structure.

Chapter guide

  1. 25.1 Introduction — Computer vision turns image measurements into descriptions or decisions about a visual scene.
  2. 25.2 Image Formation — Lighting, surfaces, geometry, optics, and sensors jointly produce pixel intensities.
  3. 25.3 Simple Image Features — Edges, corners, texture, and color summarize local patterns for later processing.
  4. 25.4 Classifying Images — A classifier assigns labels to an image, typically from features learned from labeled examples.
  5. 25.5 Detecting Objects — Detection predicts object categories and locations, often as bounding boxes.
  6. 25.6 The 3D World — Multiple cues, motion, and geometry help infer depth, shape, and spatial relationships.
  7. 25.7 Using Computer Vision — Applications include inspection, accessibility, mapping, and medical support; context and error costs matter.

Interactive: edge features

A simple synthetic scene is processed with Sobel image gradients. Raise the threshold to keep only stronger local intensity changes.

Scene ready. Choose an edge threshold.

Feature caveat. Edges can reveal boundaries, but shadows and texture also create gradients. A feature is evidence, not a complete scene interpretation.

From pixels to an edge feature

A pixel is a sampled intensity/color; grayscale collapses color channels to one intensity; an image gradient estimates how quickly intensity changes horizontally and vertically. The Sobel operator applies two 3×3 filters to estimate Gx and Gy, then uses √(Gx²+Gy²) as gradient magnitude. A pixel is marked bright when that magnitude exceeds the slider threshold. For example, a uniform patch has near-zero gradients and stays dark; a sharp boundary creates larger magnitudes and may pass the threshold. Raising the threshold suppresses weaker changes but can also erase useful edges.

The synthetic scene is fixed and noise-free; real image formation, shadows, sensor noise, texture, and occlusion complicate interpretation. Edges are local cues, not object labels or a complete 3D reconstruction.

Complexity and memory

Let W×H be image dimensions and P=WH the pixel count. One Sobel render visits each interior pixel and evaluates a constant 3×3 neighborhood, so it takes O(WH) time. The edge output and source/image buffers require O(WH) memory; the source and displayed canvases are visualization storage, while the per-render image and output buffers are algorithm workspace. The demo's fixed 360×220 image makes the work bounded. Threshold changes recompute the full map; the scan animation also redraws it per frame, so total animation work scales with the number of frames times WH.