LLGA · Course notes

Image Analysis and Computer Vision

CSC_51073_EP · Year 1 · Period 1

Contents

Introduction and overview

Module Image Analysis and Computer Vision
Code CSC_51073_EP
Team and workload Coordinator (“Responsables” and occurrence coordinator on the 2026-2027 sheet): Mathieu Brédif (IGN, ENSG · Université Gustave Eiffel); teaching team listed on the sheet: Alexandre Bry, Louis Dezons, Xi Wang · 36 h in person (lecture / small-class split not displayed) · 4.5 ECTS · image formation, filtering, edges, interest points, epipolar geometry, optical flow, and vision CNNs — up to urban LiDAR point clouds, the research field of the instructor at IGN.
Period Fall 2026 · period 1 (X-3A-P1, from 09/17/2026 to 12/18/2026) · lectures in English, small classes in English or French (occurrence language: English)
Assessment 5 small classes (TD) + 1 project — stated in the description of the sheet and in the section of the engineering degree; the LLGA section of the sheet is empty
Status in the program P1 electiveAI-systems route one of the “Choose 3” electives of Year 1 · Period 1, preselected by the AI-systems route of the home page

Audience: an engineer who has already opened an image in NumPy / OpenCV and applied a blur; no projective geometry is assumed on page 1. Empirical first: each topic starts from a failure you can observe — Canny over-sensitive to noise, a homography that breaks on a panorama, a CNN that detects better than SIFT until labels run out — and only then names the model behind it (pinhole camera, epipolar geometry, ICP).

This course is about making a machine see. It goes from optics to detection CNNs, through filtering, multi-view geometry and 3D point clouds, and it tells classical and learned vision as one story: the convolution of ch. 2 is the same operator as the one inside the CNNs of ch. 9. It ends with urban LiDAR, the research field of the instructor at IGN, and the skills it builds serve both industrial perception and the multimodal models of the program.

What you will be able to do

Official objectives and syllabus (2026-2027 catalog)

The official sheet (X3A ME1) sets the frame: “the objective of computer vision is to compute properties of the world from digital images”, with problems such as 3D shape recovery, motion estimation, or object recognition, and an introduction that “covers themes such as feature detection, motion estimation, image mosaics, and 3D vision”.

The themes are discussed “in terms of algorithms and mathematical tools”, and the applications can be developed “in Python or C++” — the algorithmic orientation of these materials.

Official prerequisites: not displayed; assessment: 5 small classes + 1 project; volume: 36 h in person. The table follows the “Programme détaillé” of the sheet, then the themes of its description.

Official program theme Course section
Light, color, and images Chapter 1: section Light (Def. 1.6 radiance, irradiance, vignetting, Lambertian shading, tone curve; Example 1.7), Def. 1.5 (Bayer and color spaces), pinhole model and sampling
Filtering, resampling, edges, and corners Chapters 2 (filtering, convolution, pyramids), 1 (Def. 1.4 sampling and aliasing), 5 (Note: inverse warping with bilinear interpolation), 3 (Canny edges), and 4 (Harris, SIFT)
3D vision: stereo Chapter 6 (epipolar geometry, rectification, disparity)
Deep learning Chapter 9 (vision CNNs: detection and segmentation)
Dense correlation image matching and MultiView Stereo Chapter 6: section Dense correlation and multi-view stereo (Def. 6.6 NCC, Example 6.7 NCC versus SSD, Def. 6.8 plane sweep), Note “modern dense stereo”, Def. 6.5
Structure from motion Chapter 6 (Def. 6.5: incremental SfM and bundle adjustment), building on the homographies and panoramas of chapter 5
Image-based… (title truncated on the sheet): read as image-based rendering Chapter 6, section Image-based rendering (Def. 6.9: panoramas, light fields, view interpolation, radiance fields; Example 6.10: interpolated view and disocclusion); mosaics in chapter 5 (Note “panoramas and warping”)
Graph cut Chapter 8 (segmentation by graph cuts)
Description: feature detection, motion estimation, image mosaics, 3D vision Chapters 4 (Harris, SIFT), 7 (optical flow), 5 (homographies, panoramas), 6 (stereo, SfM, MVS)
Description: 3D shape recovery and object recognition Chapter 6 (SfM and MVS, Def. 6.5 and 6.8) and chapter 9 (detection CNNs)
Algorithms and mathematical tools; applications in Python or C++ Every chapter (statements with proofs or worked examples), labs and exercises in Python with OpenCV

All the themes of the official program are covered. Structure from motion (Def. 6.5) was added earlier; against the 2026-2027 sheet, light (Def. 1.6), dense correlation and plane-sweep stereo (Def. 6.6–6.8) and image-based rendering (Def. 6.9–Example 6.10) were added, as they were previously only named in passing. The truncated item “Image basée sur…” is our reading (image-based rendering). Our additions, beyond the official program: the review chapter 0, chapter 10 (LiDAR point clouds, ICP, and urban analysis), and chapter 11 (the instructor’s work at IGN), which extend vision toward 3D geospatial data.

Where this course fits in the program

One of the “Choose 3” electives of Year 1 · Period 1 (36 h, 4.5 ECTS), preselected by the AI-systems route of the home page: the “vision” choice of the period. Official prerequisites: not stated on the sheet.

These materials assume two internal prerequisites. The first is Signal Processing, whose filtering, convolution, and sampling it consumes (the review chapter takes up linear algebra, convolution, and probability). The second, for the CNN chapter, is neural-network training and convolutional layers: Deep Learning, ch. 1–4, taken in the same period. The AI-systems route takes Deep Learning only in its P2 variant, after this course, so its students read ch. 1–5 of the Refresher Neural Nets before session 10; the box “CNN in one page” that opens ch. 9 adds the convolutional parts.

Downstream, three modules directly extend this one: Computer Vision: From Fundamentals to Applications (Period 2; announced in the MSc&T brochure but not in the 2026–27 LLGA lists, notes kept for reference) is its declared sequel, from fundamentals to applications; Multimodal Generative AI mobilizes visual encoders and diffusion over images; Advanced Deep Learning deepens vision architectures among advanced models. Note: the graph-cut segmentation of chapter 8 also connects vision to the “graphs” side of the master’s program, up to Graph ML.

The course is the perception front end of two end-of-year projects: the scene-graph question answering of Y1.5 (detection, ch. 9; camera and projective geometry, ch. 1 and 5) and the 3D product search of Y2.3 (point clouds, ch. 10).

Course outline

Session plan

36 h in class = 12 sessions of 3 h. The volume is the one of the SynapseS 2026–2027 sheet (36 h in person; the lecture / small-class split is not displayed); the sheet lists its programme topics but publishes no session-by-session programme, so the split below is our proposal for covering these notes in that time. Level 1 = foundations (reviews, definitions, first worked examples), 2 = core methods, 3 = advanced material (3D registration, learning on point clouds); the level never goes down from one session to the next.

Session Hours Level Content Practice
1 3 h 1 ch. 0 Review: SVD, Gaussians; ch. 1 Image formation: pinhole camera, sampling, color, light (radiance, vignetting, Lambert, tone curve) Ex. 1 (a)–(b)
2 3 h 1 ch. 2 Filtering and convolution: Gaussian, derivatives, pyramids Ex. 2
3 3 h 1 ch. 3 Edges: gradient and the Canny detector lab: Canny on noisy photos, effect of \sigma and thresholds
4 3 h 2 ch. 4 Interest points: Harris, SIFT, matching; nearest-neighbour search (kd-trees, hashing) Ex. 5
5 3 h 2 ch. 5 Homographies: DLT, RANSAC, panoramas Ex. 1 (c)–(d), Ex. 6
6 3 h 2 ch. 6 Epipolar geometry, the 8-point algorithm, rectified stereo, dense stereo (Def. 6.1–Note); dense correlation by NCC (Def. 6.6, Example 6.7) Ex. 4
7 3 h 2 ch. 6 (end) Structure from motion (Def. 6.5), MultiView Stereo by plane sweep (Def. 6.8), image-based rendering (Def. 6.9, Example 6.10) lab: two-view reconstruction with OpenCV
8 3 h 2 ch. 7 Optical flow: Lucas-Kanade, Horn-Schunck Ex. 3
9 3 h 2 ch. 8 Segmentation: k-means, graph cuts and max-flow, normalized cuts Ex. 8, Ex. 9
10 3 h 2 ch. 9 CNNs for vision: CNN in one page, detection, segmentation, training losses, metrics lab: fine-tune a pretrained detector, compute AP (lab sheet at the end of ch. 9)
11 3 h 3 ch. 10 Point clouds: LiDAR, neighborhoods and normals, Kabsch theorem Ex. 7 (start)
12 3 h 3 ch. 10 (end) ICP and its convergence, optimal transport, learning on clouds Ex. 7; project kick-off

Self-study, outside the 36 h (about 2 h in total): ch. 11 Research at IGN (Brédif): urban LiDAR — the benchmark, LU-Net and disocclusion papers, read as project preparation (≈ 2 h).

How to study this module

independent note Vision is where the two sides of the program meet: images become graphs (graph cuts, 3D scenes), and image encoders feed the multimodal models. The applications range from IGN’s digital cities to image-text models, with jobs and internship topics on both sides. A good way into the course is an image ruined by a bad filter, rather than an abstract 3×4 matrix.

0. Review: linear algebra, convolution, probability

This chapter gathers the tools from linear algebra, calculus and probability that the rest of the course uses constantly. Two results deserve to be known by heart: the singular value decomposition, which solves almost every estimation problem of the geometric chapters, and the behaviour of Gaussians under convolution, which makes the Gaussian the default smoothing kernel.

L3 review material used

  • Linear algebra: eigenvalues, eigenvectors, orthogonal matrices (R^\top R = I, they preserve norms), trace (\mathrm{tr}(AB) = \mathrm{tr}(BA)), and singular value decomposition (SVD);
  • Differential calculus: partial derivatives, gradient, Taylor expansions to order 1 and 2, chain rule;
  • Convolution and Fourier transform (see the Signal Processing module, chapters 1, 3 and 4): 1D convolution, convolution theorem, Shannon theorem; we extend them to two dimensions;
  • Probability: expectation, covariance, Gaussians, independence; least squares method and normal equations (see the Machine Learning module, chapter 2).

Theorem 0.1 — SVD and best rank-k approximation Every real matrix A \in \mathbb{R}^{m\times n} can be written A = U \Sigma V^\top with U, V orthogonal and \Sigma diagonal with entries \sigma_1 \geq \sigma_2 \geq \dots \geq 0.

Moreover, the best approximation of A in the Frobenius sense by a matrix of rank \leq k is

Key result — Eckart-Young theorem \sum_{i\leq k} \sigma_i u_i v_i^\top, \qquad \text{with error} \quad \big(\sum_{i>k}\sigma_i^2\big)^{1/2}.

Proof. Sketch. The singular vectors are the principal axes of AA^\top and A^\top A: the \sigma_i^2 are their eigenvalues.

For the approximation, note first that the truncated sum A_k = \sum_{i\leq k}\sigma_i u_i v_i^\top leaves the error A - A_k = \sum_{i>k}\sigma_i u_i v_i^\top, whose squared Frobenius norm is \sum_{i>k}\sigma_i^2 because the rank-one terms are orthogonal.

Conversely, for any X of rank \leq k, Weyl’s inequality for singular values gives \sigma_{i+k}(A) \leq \sigma_i(A - X) + \sigma_{k+1}(X) = \sigma_i(A - X), hence \|A - X\|_F^2 = \sum_i \sigma_i(A-X)^2 \geq \sum_{i>k}\sigma_i(A)^2 : no rank-k matrix does better than A_k. (The set of matrices of rank \leq k is not convex, which is why the proof goes through singular values rather than a projection argument.)

The SVD will be our permanent tool: least squares (DLT of ch. 5), decomposition of homographies, 3D orientation (Kabsch in ch. 10), surface normals.

Proposition 0.2 — Sums of independent Gaussians If X \sim \mathcal{N}(\mu_X, \sigma_X^2) and Y \sim \mathcal{N}(\mu_Y, \sigma_Y^2) are independent, then X + Y \sim \mathcal{N}(\mu_X+\mu_Y, \sigma_X^2 + \sigma_Y^2). One-line proof via characteristic functions: e^{it\mu_X - t^2\sigma_X^2/2}\cdot e^{it\mu_Y - t^2\sigma_Y^2/2} = e^{it(\mu_X+\mu_Y) - t^2(\sigma_X^2+\sigma_Y^2)/2}. ∎

Since the density of X + Y is the convolution of the two densities, the proposition says that a Gaussian convolved with a Gaussian is a Gaussian whose variances add: G_{\sigma_1} * G_{\sigma_2} = G_{\sqrt{\sigma_1^2 + \sigma_2^2}}. Immediate application: blurring an image twice, with \sigma_1 = 3 then \sigma_2 = 4 pixels, is the same as blurring it once with \sigma = 5 — the property that makes the Gaussian scale spaces of ch. 2-4 consistent.

1. Image formation: camera and sampling

Concrete scene: a 12 MP smartphone photo, you downsample ×4 with no anti-aliasing filter — moiré on grids, aliasing on text. This is not “the image looks ugly”: it is the formation model (projection + sampling) setting hard limits. This chapter links pixels to geometry before Canny, SIFT and CNNs.

What breaks Ignoring downsampling (aliasing); calibrating a camera on poorly measured points; treating a pixel as a metric measurement without a camera model. All three sabotage a stereo pipeline as badly as a poorly preprocessed CNN detector.

A digital image is the discretization of a projection of the 3D world onto a plane. Understanding the formation model is indispensable: it is what connects the pixels to geometry (ch. 5-6), and what imposes the limits of sampling (aliasing).

Definition 1.1 — Pinhole model and homogeneous coordinates The pinhole projects a 3D point X = (X_1, X_2, X_3)^\top onto the image plane Z = f along a straight line through the optical center: x = f\,X_1/X_3, y = f\,X_2/X_3.

In homogeneous coordinates \tilde{x} = (x, y, 1)^\top \sim (f X_1, f X_2, X_3)^\top, the projection becomes linear:

Key result — the projection equation \lambda\,\tilde{u} = K\,[\,R \mid t\,]\,\tilde{X},\qquad K = \begin{pmatrix} f_x & s & c_x \\ 0 & f_y & c_y \\ 0 & 0 & 1\end{pmatrix},

with R \in SO(3) the orientation, t the position, K the intrinsic parameters (focal length in pixels f_x = f/dx, principal point (c_x, c_y), skew s \approx 0).

The 3\times4 matrix P = K[R\mid t] is the projection matrix; the equality is up to a factor \lambda — all of projective geometry follows from this scale indeterminacy.

Theorem 1.2 — Projective projection preserves alignment The image by a pinhole camera of a line in space is a line (never a curve), and incidence is preserved.

Proof. A 3D line is \{X_0 + \lambda v\}; its images are P\tilde{X_0} + \lambda P\tilde{v}, that is, the vector plane of \mathbb{R}^3 spanned by P\tilde{X_0} and P\tilde{v} (provided they are independent); now the projective points belonging to a common 2-dimensional vector plane form precisely a projective line of the image plane \mathbb{P}^2. ∎

Practical consequence: rectangles do not remain rectangles (except in the frontal case), circles become ellipses, length ratios are not preserved — but alignment is. This is what makes the epipolar geometry of ch. 6 possible.

Example 1.3 — Numbers: field of view and focusing Sensor 4000×3000 pixels of 3.45 µm (physical width w = 4000 \times 3.45\,\text{µm} = 13.8 mm), lens of focal length f = 50 mm: \mathrm{FOV} = 2\arctan\frac{w/2}{f} = 2\arctan\frac{6.9}{50} = 2 \times 7.86^\circ \approx 15.7^\circ.

The same optics on a “full frame” 36 mm sensor would give 2\arctan(18/50) \approx 39.6^\circ: at equal focal length, the field depends on the sensor size — hence the use of 35 mm-equivalent focal lengths.

In pixels, f_x = f/dx = 50\,\text{mm}/3.45\,\text{µm} = 50/0.00345 \approx 14\,490 \ \text{px}.

Definition 1.4 — Sampling, folding, aliasing Discretizing an image = sampling a 2D signal: the Shannon theorem (see the Signal Processing module, ch. 4) requires a step \leq 1/(2\nu_{max}) in each direction. A real sensor cannot satisfy Shannon perfectly: frequencies beyond the Nyquist frequency (half the sampling frequency) fold over (aliasing) — moiré on fabrics, wheels turning backwards. Sensors therefore combine an optical low-pass filter (the famed “OLPF”) and the binning of photosites; software antialiasing does the same job in image synthesis.

Definition 1.5 — Color: Bayer mosaic and spaces Most sensors place behind each photosite a red, green, or blue filter according to the Bayer mosaic (2 greens for 1 red and 1 blue, human sensitivity to green dominating); demosaicing interpolates the two missing components per pixel. Color is then handled in adapted spaces: RGB for sensors, YUV/YCbCr for compression (full-resolution luminance, chrominance subsampled 4:2:0), HSV/Lab for segmentation (ch. 8: separating hue from luminance stabilizes the k-means).

Note — Distortions of real lenses The pinhole is an idealization; real optics add a radial distortion r \mapsto r(1 + k_1 r^2 + k_2 r^4) (barrel or pincushion) and a tangential distortion. Calibration (checkerboard, Zhang 2000) estimates K and the coefficients k_i, and the image is rectified before any geometric measurement: otherwise the homographies of ch. 5 lose several pixels at the edge of the field.

Light: from scene radiance to pixel value

The official programme opens with “light, colour and images”. Geometry (Definition 1.1) says where a point lands in the image; radiometry says how bright it is, which every intensity-based method of the course — edges, correlation, flow — silently depends on.

Definition 1.6 — Radiometry of image formation Light leaving a scene point toward the camera is measured by its radiance L (W·m⁻²·sr⁻¹); light arriving on a photosite by its irradiance E (W·m⁻²).

For a thin lens of focal length f and aperture diameter D, a patch of radiance L seen at the angle \alpha from the optical axis produces the image irradiance E \;=\; L\,\frac{\pi}{4}\Big(\frac{D}{f}\Big)^2 \cos^4\alpha .

Three consequences:

  • brightness does not depend on the distance to the object (radiance is conserved along a ray);
  • it scales like 1/N^2 with the f-number N = f/D;
  • it falls off toward the corners of the image (natural vignetting, \cos^4\alpha).

For a Lambertian (matte) surface of albedo \rho lit by a distant source of irradiance E_s from the direction \mathbf{l}, L = \frac{\rho}{\pi} E_s \max(0, \mathbf{n}\cdot\mathbf{l}) : brightness depends on the normal \mathbf{n}, so shading carries shape, and two cameras or two lightings see the same point with different values.

Finally the pixel value is I = g(t\,E), quantized — exposure time t, then a non-linear tone curve g (gamma; sRGB is close to x^{1/2.2}) — so pixel values are not proportional to light.

Example 1.7 — Exposure arithmetic

(i) Closing the aperture from f/2.8 to f/4 multiplies E by (2.8/4)^2 \approx 0.49: one “stop”, compensated by doubling t.

(ii) At \alpha = 20°, \cos^4\alpha = 0.940^4 \approx 0.78: the corners are 22% darker at equal radiance.

(iii) A matte wall turned 60° away from the sun receives \cos 60° = 0.5 of the light: half the radiance.

(iv) Two neighbouring sRGB pixels at 0.2 and 0.8 correspond to the linear values 0.2^{2.2} \approx 0.029 and 0.8^{2.2} \approx 0.612; the average light is 0.32, whose encoded value is 0.32^{1/2.2} \approx 0.60, \ \text{not}\ 0.5 ; averaging encoded values (when downsampling, ch. 2) darkens high-contrast areas, so one linearizes first.

Points (iii) and (iv) are why the matching costs of chapter 6 must tolerate changes of gain and offset.

2. Filtering and convolution

Filtering an image means replacing each pixel with a combination of its neighborhood: smoothing noise, sharpening details, detecting variations. The universal tool is convolution, already met in 1D in the Signal Processing module (ch. 1): everything that follows is its 2D translation.

Definition 2.1 — 2D convolution and correlation For an image I and a kernel K with finite support: (I * K)(x, y) = \sum_{i}\sum_{j} I(x-i,\,y-j)\,K(i, j). Convolution flips the kernel; correlation \sum I(x+i, y+j) K(i,j) does not — for symmetric kernels (Gaussian, box), the two coincide. A convolutional filter is linear and translation-invariant as a system — shifting the input shifts the output by the same amount, which ch. 9 calls translation equivariance. These are exactly the LTI systems of signal processing, and the convolution theorem applies: I * K \longleftrightarrow \hat I \cdot \hat K (2D Fourier transform).

Proposition 2.2 — Separability of the Gaussian The 2D Gaussian kernel factors: G_\sigma(x, y) = \frac{1}{2\pi\sigma^2}e^{-(x^2+y^2)/2\sigma^2} = g_\sigma(x)\,g_\sigma(y) \quad \text{with} \quad g_\sigma(t) = \frac{1}{\sqrt{2\pi}\sigma} e^{-t^2/2\sigma^2}. Convolving by G_\sigma therefore amounts to convolving first along rows then along columns.

Proof. The factorization is an algebraic identity: e^{-(x^2+y^2)/2\sigma^2} = e^{-x^2/2\sigma^2}\cdot e^{-y^2/2\sigma^2} \quad \text{and} \quad \frac{1}{2\pi\sigma^2} = \frac{1}{\sqrt{2\pi}\sigma}\cdot\frac{1}{\sqrt{2\pi}\sigma}. The rest follows by associativity of convolution: I * G_\sigma = I * (g_\sigma^{col} * g_\sigma^{row}) = (I * g_\sigma^{col}) * g_\sigma^{row}. ∎

Gain: a k\times k kernel costs k^2 multiplications per pixel in 2D, 2k in two passes; for k = 31: 961 → 62, i.e. 15.5× fewer. In practice one samples g_\sigma over [-3\sigma, 3\sigma] (99.7% of the mass) and normalizes the sum to 1.

Definition 2.3 — Derivatives and finite differences The discrete derivative is approximated by centered differences \frac{\partial I}{\partial x}(x, y) \approx \frac{I(x+1,y) - I(x-1,y)}{2}, that is, a convolution by \frac12[-1, 0, 1].

On a noisy image, differentiating amplifies the high-frequency noise; one smooths first: \frac{\partial}{\partial x}(G_\sigma * I) = \Big(\frac{\partial G_\sigma}{\partial x}\Big) * I, the equality coming from swapping derivative and convolution (Fubini; see the ch. 0 review and the Signal Processing module).

Conclusion: differentiating a smoothed image = convolving by the derivative of a Gaussian — a single kernel, optimal in the sense of the chosen scale. This is the starting point of ch. 3.

Example 2.4 — Common kernels and their effects

Kernel Formula / mask Effect
3×3 box all coefficients 1/9 smoothing (fast, block artifacts)
Gaussian G_\sigma smoothing (isotropic, no oscillation)
Sobel-x \frac18\begin{pmatrix}-1&0&1\\-2&0&2\\-1&0&1\end{pmatrix} horizontal derivative smoothed vertically
Laplacian \begin{pmatrix}0&1&0\\1&-4&1\\0&1&0\end{pmatrix} second derivative; edges = zero crossings
median non-linear impulse noise (salt/pepper) without blurring edges
unsharp I + \lambda\,(I - G_\sigma*I) sharpening (the “unsharp mask”)

The Sobel mask is the outer product of the smoothing \frac14[1, 2, 1]^\top and the centred derivative \frac12[-1, 0, 1] of Definition 2.3, hence the factor \frac18: on a ramp of slope a it returns exactly a. OpenCV’s cv2.Sobel omits the factor, so its output is 8 times this derivative.

Proposition 2.5 — Pyramids: subsampling without folding Halving the resolution without precaution folds the frequencies beyond the new Nyquist frequency (Def. 1.4). The Gaussian pyramid therefore applies G_{\sigma_0} (with \sigma_0 \geq \tfrac{\sqrt{2}}{2} pixel) before keeping one pixel out of two; each level I^{(k+1)} = \downarrow_2 (G * I^{(k)}) represents the image at scale 2^k. These pyramids speed up multi-scale search (ch. 4: SIFT, ch. 7: pyramidal Lucas-Kanade) and progressive rendering.

3. Edges: gradient and Canny

An edge is a rapid variation of intensity: the first order (gradient) locates it by its maxima, the second order (Laplacian) by its zero crossings. The Canny detector (1986) combines these ideas into a pipeline still present in industrial chains.

Definition 3.1 — Image gradient \nabla I = (I_x, I_y)^\top; magnitude \|\nabla I\| = \sqrt{I_x^2 + I_y^2} (rate of variation), direction \theta = \mathrm{atan2}(I_y, I_x) — edges are perpendicular to \nabla I. In the discrete setting, I_x, I_y are estimated by Sobel (Example 2.4) after Gaussian smoothing.

Example 3.2 — Gradient by hand Intensities of a neighborhood \begin{pmatrix} 52 & 54 & 55\\ 50 & 120 & 122 \\ 48 & 118 & 120\end{pmatrix} at the central point: with Sobel (Example 2.4), I_x = \frac{(55 + 2\cdot122 + 120) - (52 + 2\cdot50 + 48)}{8} = \frac{419 - 200}{8} \approx 27.4, I_y = \frac{(48 + 2\cdot118 + 120) - (52 + 2\cdot54 + 55)}{8} = \frac{404 - 215}{8} \approx 23.6. Magnitude \sqrt{27.4^2+23.6^2} \approx 36 levels/pixel, direction \theta \approx \mathrm{atan2}(23.6, 27.4) \approx 40.8^\circ , a strong, diagonal edge.

A pixel from a homogeneous area would give only a few levels/pixel under the noise: magnitude thresholding separates signal from noise.

Algorithm 3.3 — The Canny detector

  1. Gaussian smoothing G_\sigma (\sigma sets the scale of the detected edges);
  2. gradient (Sobel) → magnitude and direction;
  3. non-maximum suppression: quantize \theta into 4 directions (0°, 45°, 90°, 135°) and keep a pixel only if its magnitude exceeds that of its two neighbors in the direction of the gradient — an edge one pixel wide;
  4. hysteresis thresholding at two levels (s_{low} < s_{high}): a pixel ≥ s_{high} is a starting point; the edge is propagated to neighbors ≥ s_{low} — which reconnects edges interrupted by noise without multiplying the false positives a single low threshold would produce.

Two settings (\sigma, thresholds) — and a remarkable property: good detection/localization trade-off, implemented in a handful of milliseconds (OpenCV: cv2.Canny(img, s_low, s_high)).

Note — Zero crossings of the Laplacian (LoG) The second order detects edges as the zeros of \Delta(G*I) = (\Delta G)*I — the “LoG” kernel, close to the “difference of Gaussians” of ch. 4. The zero crossing is finer than the gradient maximum but more sensitive to noise, and the sign on either side encodes the bright/dark transition. Marr and Hildreth made it a model of the first level of the visual cortex — the biological prehistory of the convolutional networks of ch. 9.

4. Interest points: Harris and SIFT

Matching two images amounts to finding points that are distinctive and stable there: corners, blobs, local structures. Two classics organize the chapter: Harris (1988) to detect, SIFT (2004) to describe — and the CNNs of ch. 9 are their learned heirs.

Definition 4.1 — The structure tensor and the Harris criterion Measure the change of appearance of a window W shifted by (u, v): E(u, v) = \sum_{(x,y)\in W} w(x,y)\,\big[I(x+u, y+v) - I(x, y)\big]^2. A first-order Taylor expansion (I(x+u, y+v) \approx I + u\,I_x + v\,I_y) gives the quadratic form E(u, v) \approx \begin{pmatrix}u & v\end{pmatrix} M \begin{pmatrix}u\\ v\end{pmatrix},\qquad M = \sum_W w \begin{pmatrix} I_x^2 & I_xI_y \\ I_xI_y & I_y^2\end{pmatrix}, the structure tensor.

If \lambda_1, \lambda_2 are its eigenvalues: both small = flat area; one large and one small = edge; both large = corner (varies in all directions).

The Harris criterion avoids the explicit extraction of the eigenvalues:

Key result — the Harris response R = \det M - k\,(\mathrm{tr}\,M)^2 = \lambda_1\lambda_2 - k(\lambda_1+\lambda_2)^2,

with k \approx 0.04 — positive = corner, negative = edge.

Example 4.2 — Harris with numbers A window yields \sum I_x^2 = 126, \sum I_xI_y = 43, \sum I_y^2 = 18: M = \begin{pmatrix}126 & 43\\ 43 & 18\end{pmatrix}, \qquad \det M = 2268 - 1849 = 419, \qquad \mathrm{tr}M = 144, hence R = 419 - 0.04\times 144^2 = 419 - 829 = -410 < 0 \quad \to \quad \textit{edge}. The eigenvalues \lambda_{1,2} = \frac{144 \pm \sqrt{144^2 - 4\cdot419}}{2} \approx 141 \ \text{and}\ 3 confirm: one direction varies 47× more than the other.

A corner would typically have M \sim \begin{pmatrix}400 & 10\\ 10 & 380\end{pmatrix}: \det M = 152\,000 - 100 = 151\,900, \qquad \mathrm{tr}M = 780, \qquad R = 151\,900 - 0.04\times 780^2 \approx 127\,600 > 0.

Proposition 4.3 — Invariances of Harris, and its flaw The tensor M is an average of matrices \nabla I\,\nabla I^\top: under a rotation R of the image, \nabla I \mapsto R\,\nabla I, hence M \mapsto RMR^\top and the eigenvalues — hence the corner/edge decision and the response R — are rotation-invariant.

An affine change of illumination I \mapsto aI + b multiplies M by a^2 without changing the signs.

Zooming, however, changes the number of pixels participating in the corner: Harris is not scale-invariant — precisely the problem SIFT solves.

Algorithm 4.4 — SIFT: detection + description

  1. scale space: convolve with Gaussians L(x, \sigma) = G_\sigma * I for \sigma increasing by octaves; the difference of Gaussians \mathrm{DoG}(x,\sigma) = L(x, k\sigma) - L(x, \sigma) approximates the normalized Laplacian \sigma^2\Delta I, required for scale invariance;
  2. space-scale extrema: keypoints are the local extrema of DoG in the volume (x, y, \sigma) — comparison with the 26 neighbors (8 in space, 9×2 in scale);
  3. localization: refinement by a second-order Taylor expansion of DoG in (x, y, \sigma); rejection of low-contrast points and of edges via a Harris-like ratio on the 2×2 spatial Hessian H of DoG. A point is kept only if \det H > 0 and \mathrm{tr}(H)^2/\det H < (r+1)^2/r with r = 10; a larger ratio means one principal curvature dominates, an edge-like point, which is rejected;
  4. orientation: histogram (36 bins) of the gradients of a neighborhood, weighted by a Gaussian; the dominant orientation provides the canonical frame of the descriptor → rotation invariance;
  5. descriptor: around the point, 4×4 cells, each an orientation histogram with 8 bins → 4\times4\times8 = 128 values, normalized (thresholding at 0.2 for robustness to saturations) → affine illumination invariance.

Matching is done by nearest neighbor with Lowe’s ratio test: accept if d_1/d_2 < 0.8 (distance to the first neighbor over distance to the second): rejecting ambiguities costs less than tolerating false matches.

Proposition 4.5 — Cost of matching Two images with n descriptors each: the exhaustive nearest-neighbor search costs O(n^2) in 128D distance — for n = 10^4, 10^8 distances ≈ a few seconds. The kd-tree answers in O(\log n) in low dimension, but the curse of dimensionality makes approximation (kd-tree forests, FLANN, locality-sensitive hashing) indispensable in practice: section Nearest-neighbour search at the end of this chapter (Definitions 4.7–4.9).

Example 4.6 — Harris and SIFT in Python (numpy + OpenCV)

import cv2, numpy as np

img  = cv2.imread("scene.jpg", cv2.IMREAD_GRAYSCALE)
imgf = img.astype(np.float32)

# --- 1. manual Harris: structure tensor, response, thresholding
Ix = cv2.Sobel(imgf, cv2.CV_32F, 1, 0, ksize=3)
Iy = cv2.Sobel(imgf, cv2.CV_32F, 0, 1, ksize=3)
A  = cv2.GaussianBlur(Ix*Ix, (5, 5), 1.5)     # weighted local sum
B  = cv2.GaussianBlur(Ix*Iy, (5, 5), 1.5)
C  = cv2.GaussianBlur(Iy*Iy, (5, 5), 1.5)
R  = (A*C - B*B) - 0.04*(A + C)**2
corners = np.argwhere(R > 0.01 * R.max())        # relative thresholding

# --- 2. OpenCV versions
Rc = cv2.cornerHarris(imgf, 2, 3, 0.04)
sift = cv2.SIFT_create(nfeatures=2000)
kps, desc = sift.detectAndCompute(img, None)   # 128-D per keypoint
img2 = cv2.drawKeypoints(img, kps, None,
                         flags=cv2.DRAW_RICH_KEYPOINTS)

# --- 3. matching two views with Lowe's ratio test
kps2, desc2 = sift.detectAndCompute(cv2.imread("scene2.jpg", 0), None)
bf  = cv2.BFMatcher()
mch = [m for m, n in bf.knnMatch(desc, desc2, k=2) if m.distance < 0.8*n.distance]
print(len(mch), "matches kept out of", len(desc))
# and for the rest of the course: Canny + quick Hough transform
edges = cv2.Canny(img, 80, 200)

Nearest-neighbour search: kd-trees and hashing

Matching descriptors (Proposition 4.5), pairing points in ICP and estimating normals (ch. 10) all ask one question: which stored vector is closest to a query? This section is the reference of these notes for the two classical answers, trees and hashing.

Definition 4.7 — kd-tree A kd-tree stores n points of \mathbb{R}^d in a binary tree. Each node splits its points at the median of one coordinate (the one of largest spread, or the depth modulo d), until the leaves hold a few points; construction costs O(n \log n).

A query q descends to its leaf and keeps the best distance r found so far. It then backtracks: a sibling subtree is visited only if its splitting hyperplane lies closer than r to q.

Proposition 4.8 — When trees work, and when they fail In low dimension (image positions, 3D clouds) few hyperplanes cross the ball of radius r around q, and a query costs O(\log n) on average.

In 128 dimensions that ball crosses almost every splitting hyperplane: backtracking visits most leaves, no better than brute force. Approximate search therefore bounds the work:

  • best-bin-first visits the leaves in order of distance to their cells and stops after a fixed number of them (Beis and Lowe, 1997, for shape indexing; SIFT later adopted it for matching, Lowe 2004);
  • randomized kd-tree forests search several trees split on random coordinates;
  • FLANN (Muja and Lowe, 2009) picks the index and its parameters automatically; it is OpenCV’s cv2.FlannBasedMatcher.

Definition 4.9 — Locality-sensitive hashing by random hyperplanes Draw \mathbf{r} \in \mathbb{R}^d with independent \mathcal{N}(0, 1) entries and set h(\mathbf{x}) = \mathrm{sign}(\mathbf{r}^\top \mathbf{x}) . For two vectors at angle \theta (Charikar, 2002), \mathbb{P}\big[h(\mathbf{x}) = h(\mathbf{y})\big] = 1 - \theta/\pi .

Concatenate k such bits into a bucket key and build L independent tables. A pair at angle \theta shares a bucket in at least one table, and becomes a candidate, with probability P_{\text{cand}}(\theta) = 1 - \big(1 - (1 - \theta/\pi)^k\big)^L , and only candidates are compared exactly.

Example 4.10 — Choosing k and L Take k = 16 bits and L = 20 tables.

  • A true match at \theta = 20°: 1 - \theta/\pi = 0.889 and 0.889^{16} = 0.152, so P_{\text{cand}} = 1 - 0.848^{20} \approx 0.96.
  • An unrelated descriptor at \theta = 60°: 0.667^{16} \approx 0.0015, so P_{\text{cand}} \approx 0.03.

About 96% of the true matches survive, while only 3% of the unrelated descriptors are compared exactly. Raising k sharpens the threshold; raising L recovers recall.

The same indexes, together with graph-based ones such as HNSW (Malkov and Yashunin, 2018), serve the dense retrieval of a RAG pipeline (NLP, section 7.4); the banding of MinHash LSH follows the same formula.

5. Projective geometry and homographies

Two views of the same plane (facade, document, whiteboard), or one camera that only rotates about itself: in both cases, the relation between pixels is a homography. It is the basic tool of registration, panoramas, and augmented reality.

Definition 5.1 — Homography A homography is a projective map of the plane \mathbb{P}^2 defined by a matrix H \in \mathbb{R}^{3\times3} of rank 3, up to a scale factor: \tilde{x}' \sim H\tilde{x}.

It therefore has 9 - 1 = 8 degrees of freedom: 4 pairs of points (2 independent equations each) suffice to determine it.

In \mathbb{P}^2, points and lines are in duality: the line through x_1, x_2 is l = x_1 \times x_2, the intersection point of l_1, l_2 is l_1 \times l_2, and a homography carries points and lines (l' \sim H^{-\top} l).

Theorem 5.2 — When a homography applies The relation between two views is a homography if (i) the scene is planar, or (ii) the camera undergoes only a pure rotation about its optical center.

Proof. Case (i): plane \Pi = \{\tilde{X} : \tilde{n}^\top \tilde{X} = d\} in the frame of camera 1, relative motion (R, t). For X \in \Pi: X_2 = R X_1 + t = (R + t\,\tilde{n}^\top/d)\,X_1 , the depth is eliminated in favor of a 3×3 linear combination; with u_1 \sim K_1 X_1 it follows that u_2 \sim K_2 (R + t\tilde n^\top/d) K_1^{-1} u_1 = H u_1.

Case (ii): if t = 0, P = K R and \tilde{u}_2 \sim K_2 R_2 R_1^\top K_1^{-1}\,\tilde{u}_1 , a 3\times3 product, and we are done. ∎

Proposition 5.3 — Direct linear estimation (DLT) Each correspondence \tilde{x} \leftrightarrow \tilde{x}' provides \tilde{x}' \times (H\tilde{x}) = 0, i.e. 2 linear equations in the 9 coefficients of H (up to scale, one fixes \|h\| = 1).

With n \geq 4 correspondences, the system Ah = 0 (2n \times 9) is solved by SVD: h is the right singular vector associated with the smallest singular value — the “smallest residual” version of homogeneous least squares.

Golden rule: normalize the points before DLT (translate the centroid to the origin, scale so that the mean distance is \sqrt2; Hartley) — otherwise the conditioning degrades the solution by several orders of magnitude.

With noisy correspondences, the DLT minimizes only an algebraic error; one then refines H by Levenberg-Marquardt on the geometric (reprojection) error \sum_i \|x'_i - \pi(H\tilde{x}_i)\|^2, where \pi(a, b, c) = (a/c, b/c) returns to pixel coordinates.

Proposition 5.4 — RANSAC: estimating amid outliers SIFT correspondences contain false positives. The RANSAC paradigm (RANdom SAmple Consensus) draws at random a minimal set of points (here 4), estimates H, counts the inliers (residual < \varepsilon), repeats, and refines the model on the best consensus.

With a proportion w of inliers and 4 points drawn: probability that a draw is clean = w^4; for a success rate p after N draws:

Key result — number of RANSAC draws N \;\geq\; \frac{\log(1-p)}{\log(1-w^4)}.

Worked example: 50% inliers, p = 0.99 → N = \frac{-4.605}{\ln(1 - 0.0625)} = \frac{-4.605}{-0.0645} \approx 72 \ \text{draws}. At 90% inliers: w^4 = 0.656, N = \frac{-4.605}{\ln 0.344} = \frac{-4.605}{-1.067} \approx 4.3, i.e. 5 draws.

The cost is trivial compared to least squares on contaminated data — and the model extends to any pair (minimal estimator, number of inliers).

Note — Panoramas and warping Assembling a panorama: SIFT correspondences between pairs of neighboring images → homographies by RANSAC → a global “bundle adjustment” to avoid drift → final projection (plane, cylindrical, or spherical depending on the angular amplitude). Warping is written in inverse coordinates: for each output pixel, x = H^{-1}x', then bilinear interpolation — interpolating in the forward direction would leave holes.

6. Stereo vision and epipolar geometry

Two views of a 3D scene, taken from different points: the epipolar constraint says that the correspondent of a pixel lies on a known line in the second image. All of stereo vision — from reconstruction to robotics — follows from this geometric observation.

Definition 6.1 — Epipolar geometry, F and E Consider a pair of cameras P_1 = K_1[I \mid 0], P_2 = K_2[R \mid t].

The 3D point X projects to x_1 and x_2; the epipolar plane passes through X, x_1, x_2, and the two optical centers.

Its intersection with image plane 2 is the epipolar line of x_1 — every match must live on it. The constraint reads

Key result — the epipolar constraint \tilde{x}_2^\top F\, \tilde{x}_1 = 0,\qquad F = K_2^{-\top} [t]_\times R\, K_1^{-1},

F is the fundamental matrix (rank 2, 7 dof); its version normalized by the intrinsic matrices, E = K_2^\top F\,K_1 = [t]_\times R, is the essential matrix (5 dof): it depends only on the relative motion.

Proposition 6.2 — The 8-point algorithm Each match \tilde{x}_1 \leftrightarrow \tilde{x}_2 gives one linear equation in the 9 coefficients of F; 8 matches suffice (hence the name). Solve by SVD of the homogeneous system, then project onto the set of rank-2 matrices (replace the smallest singular value by 0: F = U\,\mathrm{diag}(\sigma_1, \sigma_2, 0)\,V^\top). The normalization of the points (Prop. 5.3) is again crucial here. Next: decomposition of E (SVD) into 4 candidate (R, t) pairs, ambiguity resolved by the chirality test (the reconstructed points must lie in front of the cameras). This is “calibrated stereo”; the uncalibrated version stops at F.

Theorem 6.3 — Rectified stereo: disparity and depth After rectification (resampling of both images so that the epipolar lines are the horizontal lines — a pair of homographies, ch. 5), a point at depth Z is seen at abscissae x_1, x_2 with d = x_1 - x_2 = \frac{f\,B}{Z}\;\;\Longleftrightarrow\;\; Z = \frac{fB}{d}, f: focal length in pixels, B: baseline (distance between cameras), d: disparity.

Proof. Elementary triangulation: the 3D point (X, Y, Z) projects to x_1 = fX/Z in the left camera; the right camera, translated by B along the X axis (the baseline, perpendicular to the parallel optical axes), sees x_2 = f(X - B)/Z.

The difference x_1 - x_2 = fB/Z no longer depends on X: disparity encodes depth. ∎

Example 6.4 — Orders of magnitude (KITTI style) f = 721 px, B = 0.54 m. A car at Z = 39 m has a disparity d = fB/Z = 721\times0.54/39 \approx 10 \ \text{px}; at 10 m, d \approx 39 px.

Error: since Z = fB/d is non-linear, \Delta Z/Z = \Delta d/d, that is \Delta Z \approx \frac{Z^2}{fB}\,\Delta d . An uncertainty of ±0.2 px on d = 10 px gives ±2% (±0.8 m); on d = 3 px (130 m), ±7% — stereo sees far away poorly: precision degrades with the square of the distance, hence the value of large baselines or LiDAR (ch. 10).

Theorem 6.3 and this error formula are the reference statements of these notes; Computer Vision Applications, ch. 6 recalls them for applied stereo and LiDAR.

Note — Modern dense stereo The classic pipeline: per-pixel local cost (SSD/SAD over windows, or the illumination-robust census transform), aggregation and regularization by per-row dynamic programming, or semi-global matching (Hirschmüller, 2008): minimize a global energy by summing costs over 8 directions — the industrial standard for depth maps, up to learned stereo networks (PSM-Net etc.) that process the image pair end to end. Triangulation of an isolated match is solved, for its part, as a linear system: \tilde{x} \times (P\tilde{X}) = 0 provides 2 equations per camera, 4 for the pair — SVD, again.

Definition 6.5 — Structure from motion (SfM) and MultiView Stereo The image pair of the chapter generalizes to n unordered views:

  • Structure from motion (SfM): recovering both the camera poses and the 3D structure. Incremental pipeline (COLMAP): SIFT matches (ch. 4) filtered by RANSAC on F then E (Prop. 6.2) → well-conditioned initial pair, decomposition of E into (R, t), triangulation → views added one by one by resection (DLT, ch. 5), additional 3D points by triangulation; the whole is refined by bundle adjustment: global minimization of the reprojection error \sum_{i,j} \big\| x_{ij} - \pi(P_j X_i) \big\|^2 over poses and points (Gauss-Newton / Levenberg-Marquardt on the sparse system).
  • MultiView Stereo (MVS): poses known, one densifies — dense correlation (the Note above) applied to several pairs to produce depth maps, then fusion into a global point cloud by visibility and geometric consistency tests; this is modern “photogrammetry”, which meets the LiDAR clouds of ch. 10.

SfM and MVS close the loop of the course: features (ch. 4), geometry (ch. 5, 6), and dense correspondences manufacture, from images alone, the 3D scene and the poses — exactly the “3D shape recovery” that the course sheet gives as its objective.

Dense correlation and multi-view stereo

Feature matching (ch. 4) gives a few thousand correspondences; dense stereo needs one per pixel. The official programme names the tool: matching by dense correlation, then its generalization to many views (MultiView Stereo).

Definition 6.6 — Window matching by normalized cross-correlation On a rectified pair (Theorem 6.3), take a window W around the pixel (x, y) of I_1 and a candidate disparity d; let

  • \mathbf{a} be the vector of intensities of W at (x, y) in I_1, with mean \bar a,
  • \mathbf{b} the vector of intensities of W at (x - d, y) in I_2, with mean \bar b.

The normalized cross-correlation is \mathrm{NCC}(d) \;=\; \frac{\sum_k (a_k - \bar a)(b_k - \bar b)}{\sqrt{\sum_k (a_k - \bar a)^2\,\sum_k (b_k - \bar b)^2}} \;\in\; [-1, 1].

Dense correlation keeps, for every pixel, d^\ast = \arg\max_{d_{\min} \leq d \leq d_{\max}} \mathrm{NCC}(d) (winner takes all), optionally refined to sub-pixel precision by a parabola through the scores at d^\ast - 1, d^\ast, d^\ast + 1.

Unlike the SSD \sum_k (a_k - b_k)^2, NCC is unchanged when \mathbf{b} becomes \alpha\mathbf{b} + \beta with \alpha > 0: it ignores the differences of gain and offset between the two cameras (Example 1.7).

Cost: |W| operations per pixel and per disparity, made independent of |W| by running sums (integral images).

Example 6.7 — Correlation versus SSD on one scanline The left window is \mathbf{a} = (10, 20, 30). The right image is brighter and has a higher gain, and the three candidate windows are \mathbf{b}_1 = (45, 65, 35), \mathbf{b}_2 = (25, 45, 65) and \mathbf{b}_3 = (15, 25, 45) for d = 1, 2, 3.

Centred, \mathbf{a} \to (-10, 0, 10) and \mathbf{b}_2 \to (-20, 0, 20), so \mathrm{NCC}(2) = 400/\sqrt{200 \times 800} = 1 : a perfect match (\mathbf{b}_2 = 2\mathbf{a} + 5).

For d = 3, \mathbf{b}_3 \to (-13.3, -3.3, 16.7) and \mathrm{NCC}(3) = 300/\sqrt{200 \times 466.7} \approx 0.98 ; for d = 1, \mathrm{NCC}(1) = -100/\sqrt{200 \times 466.7} \approx -0.33 . NCC chooses d = 2.

The SSD gives 2075, 275 and 3275 for d = 2, 3, 1: it chooses d = 3, the window whose raw values happen to be closest — wrong.

The small gap between 1 and 0.98 also shows why windows must be large enough, and why the semi-global regularization of the Note above helps.

Definition 6.8 — Multi-view stereo by plane sweep With n calibrated views whose poses come from SfM (Definition 6.5), choose a reference view and depth hypotheses Z_1 < \dots < Z_m.

The fronto-parallel plane Z = Z_k of the reference camera induces, for each other view j with relative motion (R_j, t_j), the homography H_{jk} = K_j\big(R_j + t_j\,\mathbf{n}^\top/Z_k\big)K_{\text{ref}}^{-1} \quad \text{with} \quad \mathbf{n} = (0, 0, 1)^\top (Theorem 5.2 (i)).

Warp every view onto the reference through H_{jk} and score each pixel by its photo-consistency — the mean NCC between the reference window and the warped windows of the views where the point is visible. The depth map keeps, per pixel, the best-scoring Z_k; the depth maps of several reference views are then fused into one cloud (Definition 6.5).

The plane sweep is the dense correlation of Definition 6.6 with depth in place of disparity, valid for any number of views and without rectification.

Image-based rendering

The programme item truncated on the sheet as “Image basée sur…” is read here as image-based rendering (together with the mosaics of chapter 5): producing new views of a scene directly from photographs.

Definition 6.9 — Image-based rendering (IBR) IBR renders a view from a new viewpoint by resampling captured images rather than by rendering a modelled 3D scene. Methods differ by how much geometry they use:

  • none — a panorama (ch. 5) renders any viewing direction from a fixed centre, and a light field samples the radiance along a two-dimensional family of viewpoints and renders a new view by interpolating rays (Levoy and Hanrahan; Gortler et al., both 1996);
  • per-pixel depth — view interpolation from disparity or depth maps (Example 6.10);
  • full geometry — the textured meshes produced by SfM and MVS.

Learned radiance fields (NeRF, 2020; 3D Gaussian splatting, 2023) are the current form of IBR, optimized from images whose poses come from SfM.

Example 6.10 — Interpolating a view between a rectified pair A virtual camera translated by \alpha B along the baseline (0 \leq \alpha \leq 1) sees the point (X, Y, Z) at x_\alpha = f(X - \alpha B)/Z = x_1 - \alpha\,d (proof of Theorem 6.3): each pixel moves by the fraction \alpha of its disparity.

With the numbers of Example 6.4, a pixel of the left image at x_1 = 400 on the car at 39 m (d \approx 10 px) lands at x_{0.5} = 395 in the middle view, while a background pixel with d = 2 px moves by only 1 px.

Two pixels may land on the same position: the one with the larger disparity, hence the closer, wins (a z-buffer on d).

Positions that no left pixel reaches — the background revealed beside the car — are holes, filled from the right image, warped by x_\alpha = x_2 + (1 - \alpha)\,d, or by inpainting: disocclusion is the central difficulty of IBR, and the same problem reappears for LiDAR in ch. 11.

7. Optical flow: Lucas-Kanade

The apparent motion of luminances between two images — optical flow — is the ingredient of tracking, video compression, and navigation. Lucas-Kanade (1981) remains the reference formulation, and its mathematics is a condensed version of the course.

Definition 7.1 — Gradient constraint and the aperture problem Luminance conservation assumption: I(x + u, y + v, t + \Delta t) = I(x, y, t). First-order Taylor expansion: I_x u + I_y v + I_t = 0 \qquad (\text{with } u = dx/dt,\; v = dy/dt,\; I_t = \partial I/\partial t), a single equation for two unknowns (u, v): the line of possible flows. Locally, an aperture (small window) does not suffice to determine the motion of an edge — this is the aperture problem, or the illusion of the wheel turning behind a slot.

Theorem 7.2 — Lucas-Kanade: least squares over a window Assuming the flow is constant in a window W, each pixel provides a gradient constraint; the optimal flow minimizes J(u, v) = \sum_{(x,y)\in W} w(x,y)\,\big(I_x u + I_y v + I_t\big)^2. Setting the gradient to zero (\partial J/\partial u = \partial J/\partial v = 0) yields the normal equations \underbrace{\begin{pmatrix}\sum w\,I_x^2 & \sum w\,I_xI_y\\ \sum w\,I_xI_y & \sum w\,I_y^2\end{pmatrix}}_{=\,M,\ \text{the structure tensor!}} \begin{pmatrix}u\\ v\end{pmatrix} = -\begin{pmatrix}\sum w\,I_xI_t\\ \sum w\,I_yI_t\end{pmatrix}.

Proof. Derivative with respect to u: 2\sum w\,I_x(I_xu + I_yv + I_t) = 0 → first row; symmetrically for v → second row. The matrix M is exactly Harris’s structure tensor (Def. 4.1): Lucas-Kanade is solvable precisely where Harris detects a corner — same large \lambda_1, \lambda_2. ∎

Domain of validity: small motions (Taylor), locally constant flow — hence the two remedies: (i) iterative resolution by successive warping; (ii) coarse-to-fine approach via a pyramid (Prop. 2.5): estimate large at the coarse scale, refine while going down.

Example 7.3 — A 2×2 system by hand Window of 4 pixels, gradients and time derivative (I_x, I_y\,;\,I_t): (3, 1; 8), (5, 2; 10), (4, 2; 9), (6, 3; 12).

Sums: M = \begin{pmatrix}9+25+16+36 & 3+10+8+18\\ \cdot & 1+4+4+9\end{pmatrix} = \begin{pmatrix}86 & 39\\ 39 & 18\end{pmatrix}, right-hand side -\big(\sum I_xI_t, \sum I_yI_t\big) = -(182, 82).

Let us solve: \det M = 86\times18 - 39^2 = 1548 - 1521 = 27 — nearly singular (eigenvalues ≈ 103.7 and 0.26: nearly aligned gradients). Cramer’s formulas: u = \frac{-182\times18 + 82\times39}{27} = \frac{-78}{27} \approx -2.89, \qquad v = \frac{86\times(-82) + 39\times182}{27} = \frac{46}{27} \approx 1.70.

The flow is computable but unreliable: \lambda_2 \ll \lambda_1 signals an edge, not a corner — Example 4.2 gave the opposite diagnosis on another tensor. In practice: require \lambda_2 > \tau before trusting the flow (and weight by the distance to the centroid to smooth).

Note — Horn-Schunck, the global version Instead of a window, Horn-Schunck (1981) regularizes over the whole image: minimize \int (I_xu + I_yv + I_t)^2 + \lambda\,\big(\|\nabla u\|^2 + \|\nabla v\|^2\big) : data attachment (gradient constraint) + a smooth flow field. The Euler-Lagrange equations are solved iteratively; \lambda tunes the data/regularity trade-off — the same energy structure as the graph cuts of ch. 8, and as many inverse problems of the Signal Processing module. Modern variant: learned networks supervised by these very energies.

8. Segmentation: k-means and graph cuts

Segmenting means partitioning the image into coherent regions: objects of interest, surfaces, backgrounds. Two families: the clustering approach (pixels are points in a feature space) and the energy-based approach (look for a partition that minimizes a global cost).

Definition 8.1 — k-means on pixels Each pixel becomes a vector z_i — RGB, or RGB + (\alpha x, \alpha y) to account for spatial proximity, or Lab — and one partitions \{z_i\} into k groups by minimizing J = \sum_{j=1}^{k}\sum_{i \in C_j} \|z_i - \mu_j\|^2. Lloyd’s algorithm alternates assignment to the nearest centroid then recentering — each step decreases J, hence convergence in a finite number of steps (to a local minimum; k-means++ initialization or several restarts mitigate its variance — see the Machine Learning module, ch. 7).

Example 8.2 — k-means in grayscale, by hand Intensities \{10, 12, 11, 40, 42, 90\}, k = 2, initial centroids 10 and 40.

  1. Assignment: 10, 12, 11 → C_1 (distances 0, 2, 1 versus 30, 28, 29); 40, 42, 90 → C_2.
  2. Recentering: \mu_1 = 11, \mu_2 = 57.3.
  3. Second pass: no reassignment (12 remains at distance 1 versus 45.3…): convergence.

J = (1+1+0) + (17.3^2 + 15.3^2 + 32.7^2) \approx 1605.

This fixed point is only a local minimum. The partition \{10, 11, 12, 40, 42\} \mid \{90\}, with centroids 23 and 90, is also a Lloyd fixed point (40 and 42 are closer to 23 than to 90), and it costs J = 13^2 + 12^2 + 11^2 + 17^2 + 19^2 + 0 = 1084 , the global minimum for k = 2.

Here the initialization, not k, is the problem. Several restarts find the better partition, and k-means++ usually does too: starting from 10, it draws 90 as the second centroid with probability 6400/8329 \approx 0.77 (squared distance over the sum of squared distances).

Definition 8.3 — Segmentation by graph cuts (binary) Graph: vertices = pixels (+ source s and sink t); neighborhood edges weighted by similarity B_{pq} \propto e^{-\|z_p - z_q\|^2/2\sigma^2} and terminal edges by the fit to the seeds provided by the user (Boykov-Jolly mode): R_p(s), R_p(t).

The minimum cut separates s and t and defines the segmentation. By the max-flow min-cut theorem its capacity equals the maximum flow from s to t, which is computed in polynomial time (Algorithm 8.4).

The energy formulation: E(L) = \sum_p R_p\big(L_p\big) + \lambda \sum_{(p,q)\ \text{neighbors}} B_{pq}\,\big[L_p \neq L_q\big], data attachment + boundary regularization (Potts model); it is exactly minimizable by a cut if the interaction terms are “submodular” (here: B_{pq} \geq 0).

For k > 2 labels, the problem becomes NP-hard: alpha-expansion (Boykov) gives a 2-approximation that remains practically unbeatable.

Algorithm 8.4 — Maximum flow by augmenting paths Edge u \to v has capacity c(u, v) \geq 0 and carries a flow f(u, v). Its residual capacity is c(u, v) - f(u, v) + f(v, u): what can still be pushed forward, plus what can be cancelled backward.

  1. Start from the zero flow.
  2. While the residual graph has a path from s to t (an augmenting path), push along it its bottleneck, the smallest residual capacity on the path.
  3. When no path remains, let S be the set of vertices reachable from s in the residual graph. The edges from S to the rest are saturated and those entering S carry no flow, so the cut (S, \bar S) has the capacity of the flow: it is a minimum cut, and the pixels of S take the source label.

With any path choice this is the Ford-Fulkerson method: it is only pseudo-polynomial with integer capacities and may not terminate with irrational ones. Shortest paths found by breadth-first search (Edmonds-Karp) give O(|V|\,|E|^2), and push-relabel is polynomial too.

On the grid graphs of vision the Boykov-Kolmogorov algorithm (2004), which reuses its search trees, is the practical choice. The general statement and a proof sketch are in Refresher in Computer Science, section 7.6.

Example 8.5 — A two-pixel cut by hand The edge s \to p carries the cost of labelling p background (it is cut when p falls on the sink side), and p \to t the cost of labelling it foreground.

  • Pixel p prefers the foreground: c(s, p) = 5, c(p, t) = 1.
  • Pixel q prefers the background: c(s, q) = 1, c(q, t) = 4.
  • They are neighbours, with \lambda B_{pq} = 2 in both directions.

Augmenting paths: s \to p \to t carries 1, s \to q \to t carries 1, and s \to p \to q \to t carries 2, the residual capacity of p \to q. The flow is 4.

Then S = \{s, p\}: p is foreground, q background, and the cut c(s, q) + c(p, t) + \lambda B_{pq} = 1 + 1 + 2 = 4 equals the flow.

With \lambda B_{pq} = 4 the same computation gives a flow of 5 and S = \{s, p, q\}: separating the pixels now costs more than relabelling q, and the smoothness term pulls q into the foreground.

Note — Normalized cuts and the Fiedler vector On the same pixel graph, take the affinities A_{pq} = B_{pq} and the degrees D_{pp} = \sum_q A_{pq}. Shi and Malik (2000) minimize \mathrm{Ncut}(S) = \frac{\mathrm{cut}(S, \bar S)}{\mathrm{vol}(S)} + \frac{\mathrm{cut}(S, \bar S)}{\mathrm{vol}(\bar S)}, which, unlike the plain cut, penalizes tiny segments (\mathrm{vol} sums the degrees).

Relaxing the indicator of S to real values gives (D - A)\,\mathbf{y} = \lambda D\,\mathbf{y}, that is, an eigenproblem for L_{\mathrm{sym}} = I - D^{-1/2} A\, D^{-1/2}, \qquad \mathbf{z} = D^{1/2}\mathbf{y} .

Its eigenvalues are sorted upward, 0 = \lambda_1 \leq \lambda_2 \leq \dots; thresholding \mathbf{y} = D^{-1/2}\mathbf{z}_2, where \mathbf{z}_2 is the eigenvector of \lambda_2 (the Fiedler vector), gives the bipartition. This is the spectral clustering of Graph ML, ch. 4.

Proposition 8.6 — The spectrum of approaches

Method Idea Strengths / limits
thresholding / Otsu bimodal histogram instant / no geometry
k-means (SLIC superpixels) space-color clustering simple, fast / no connectivity, choice of k
graph cuts global energy min-cut binary-optimal, interactive seeds / weights to tune
normalised cuts relaxed Ncut, Fiedler vector global, elegant / costly eigenvectors — see the Graph ML module, ch. 4 (spectral clustering)
Felzenszwalb-Huttenlocher minimum spanning tree nearly linear, hierarchical / scale parameter
watershed watershed lines respects contours / over-segments (hence markers)

9. CNNs for vision: detection and segmentation

Convolutional networks, introduced in ch. 4 of the Deep Learning module, have absorbed a large part of the classical pipeline: learned filters replace Sobel and SIFT. This chapter focuses on vision tasks: classifying, detecting (where are the objects?), segmenting (which pixels belong to them?).

CNN in one page

  • A convolutional layer is a learned filter bank (ch. 2). From C_{\text{in}} input maps x_{c'} it computes C_{\text{out}} maps, each a sum of 2D convolutions with its own kernels, plus a bias: z_c = \mathrm{ReLU}\Big(\sum_{c'=1}^{C_{\text{in}}} K_{c c'} * x_{c'} + b_c\Big). A 3\times3 layer has 9\,C_{\text{in}}C_{\text{out}} weights whatever the image size; the first layers learn Sobel- and Gabor-like kernels.
  • Pooling and stride halve the resolution, like a pyramid level (Proposition 2.5) but without the anti-aliasing blur; after each halving, every further 3\times3 layer widens the receptive field twice as fast. A final global average pooling averages each map over the whole image.
  • Residual block (ResNet, He et al. 2015): y = \mathrm{ReLU}(x + \mathcal{F}(x)), where \mathcal{F} is two convolutions with batch normalization; the identity path lets gradients cross hundreds of layers.
  • Training: the last layer gives one score s_k per class, the softmax turns the scores into probabilities \hat p_k, and the cross-entropy \ell(\hat{\mathbf p}, y) = -\log \hat p_y is minimized by minibatch SGD. Backpropagation gives the gradient of the mean loss \mathcal{L} over the minibatch, and a plain step is \theta \leftarrow \theta - \eta\,\nabla_\theta \mathcal{L} ; with momentum \beta (typically 0.9) the step follows v \leftarrow \beta v + \nabla_\theta \mathcal{L}, an exponentially weighted sum of the past gradients, instead of the last gradient alone.
  • Which route. Students of Deep Learning find the full treatment in its ch. 4. The AI-systems route takes Deep Learning only in its P2 variant, after this course: its students read ch. 1–5 of the Refresher Neural Nets (forward pass, loss, backpropagation, SGD to Adam) before session 10, and this box adds the convolutional parts.

Proposition 9.1 — Why convolution suits images Three inductive biases together: (i) shared weights: the same filter slides everywhere — translation equivariance (shifting the image shifts the feature maps, up to the stride) and a parameter count independent of image size; invariance to position comes only from pooling or global aggregation; (ii) local connectivity: each neuron sees only a neighborhood — the receptive field grows with depth; (iii) hierarchy: edges → motifs → parts → objects, learned rather than programmed.

The residual connections of ResNet (y = \mathcal{F}(x) + x, He et al. 2015) allow depths of hundreds of layers by short-circuiting vanishing gradients (see the Deep Learning module, ch. 4); transfer learning — reusing a ResNet trained on ImageNet as a feature extractor — remains the first step of any project with scarce data (ibid., ch. 7).

Definition 9.2 — Detection: two families Detection returns boxes (x, y, w, h) + class + score.

Two-stage: R-CNN (2014) proposes regions, a CNN classifies them; Fast R-CNN shares the computations; Faster R-CNN (2015) has the proposals generated by an anchor-based (boxes of predefined sizes/ratios) Region Proposal Network — top accuracy at the time.

One-stage: YOLO (2015) cuts the image into a grid and directly regresses boxes + classes per cell, in a single pass — the precision/speed trade-off that opened embedded vision.

NMS (non-maximum suppression) eliminates redundant boxes: sort by decreasing score, keep the first, remove all those whose overlap (IoU) exceeds a threshold (~0.5), iterate.

Anchor-free detectors and transformer-based models (DETR: learnable queries + attention, set prediction with Hungarian matching — attention in Deep Learning, ch. 6, the Hungarian algorithm in Refresher in Computer Science, section 7.7) close the loop: end of manual NMS, set detection.

Definition 9.3 — Semantic segmentation and U-Net Decision per pixel (each receives a class); instance segmentation additionally distinguishes objects of the same class, panoptic unifies the two. The U-Net architecture (Ronneberger et al., 2015): a contracting encoder (global context) then an expansive decoder with skip connections that reinject fine resolutions — because the per-pixel decision requires both semantics (deep) and localization (fine); the decoder learns to “re-blend” the two.

Trainable with few images (aggressive geometric augmentation), U-Net has become the universal tool: medical imaging, inspection, and — in ch. 11 — LiDAR as depth images.

Definition 9.4 — Metrics: IoU and mAP The intersection-over-union between predicted boxes (or masks) P and ground truth G: \mathrm{IoU} = |P \cap G|\,/\,|P \cup G| (areas, or pixel counts for masks) — a prediction is a true positive if \mathrm{IoU} \geq \tau (typically 0.5), if the class is correct, and if that ground truth is not already matched by a higher-scored detection (a duplicate is a false positive).

Average precision (AP): sort the detections by decreasing score, plot the (recall, precision) points, integrate (area under the curve); mAP averages the APs over classes — and sometimes over IoU thresholds (COCO: mAP@[0.5:0.95]).

Example 9.5 — AP by hand (1 class, IoU threshold 0.5) Detections sorted by score: D_1 (IoU 0.8), D_2 (IoU 0.3), D_3 (IoU 0.6), D_4 (IoU 0.55 with an object already covered) — 2 objects in total. Cumulative counts:

Detection TP/FP Cumulative TP Cumulative FP Precision Recall
D1 (0.8) TP 1 0 1.00 0.5
D2 (0.3) FP 1 1 0.50 0.5
D3 (0.6) TP 2 1 0.67 1.0
D4 (duplicate) FP 2 2 0.50 1.0

AP = area under the precision-recall curve (decreasing envelope): with “all-point” interpolation, \mathrm{AP} \approx 1.0\times0.5 + 0.67\times0.5 = 0.83. The benchmark datasets (ImageNet for classification, COCO for detection/segmentation, Cityscapes for streets) dictate architectures as much as the literature does.

These statements of IoU, NMS (Definition 9.2), AP and mAP are the reference ones of these notes; Computer Vision Applications recalls them in its ch. 0 and 2 and builds the COCO protocol on them.

Definition 9.6 — Training losses for detection and segmentation A detector is trained on the anchors (or proposals) matched to a ground-truth box, typically with IoU ≥ 0.5; the other anchors are background. The loss is \mathcal{L} = \mathcal{L}_{\text{cls}} + \lambda_{\text{box}}\,\mathcal{L}_{\text{box}} .

  • Classification: cross-entropy over the K classes plus background, on every anchor.
  • Box regression, on positive anchors only, on the offsets of the matched box (x, y, w, h) (centre, width, height) from the anchor box (x_a, y_a, w_a, h_a): t_x = \frac{x - x_a}{w_a},\quad t_y = \frac{y - y_a}{h_a},\quad t_w = \log\frac{w}{w_a},\quad t_h = \log\frac{h}{h_a}, each penalized by the smooth-L1 loss of Fast R-CNN, quadratic near 0 and linear for large errors: \mathrm{sL1}(u) = \begin{cases} u^2/2 & \text{if } |u| < 1,\\ |u| - 1/2 & \text{otherwise.}\end{cases}
  • GIoU loss (Rezatofighi et al., 2019): 1 - \mathrm{GIoU}, with C the smallest box enclosing P and G and \mathrm{GIoU}(P, G) = \mathrm{IoU}(P, G) - \frac{|C \setminus (P \cup G)|}{|C|} \in (-1, 1] . Unlike 1 - \mathrm{IoU}, it still has a gradient when the boxes do not overlap.
  • Focal loss (Lin et al., 2017): one-stage detectors face thousands of easy background anchors per object, and the focal loss down-weights them — Computer Vision Applications, Definition 1.4.
  • Segmentation: per-pixel cross-entropy averaged over the pixels. For a small foreground (lesions, poles in a LiDAR scan) the soft Dice loss is not swamped by the background: \mathcal{L}_{\text{Dice}} = 1 - \frac{2\sum_i p_i g_i}{\sum_i p_i + \sum_i g_i}, with p_i the predicted foreground probability of pixel i and g_i \in \{0, 1\} its label.

Example 9.7 — When IoU gives no signal Boxes are written (x_1, y_1, x_2, y_2). Ground truth G = (3, 0, 5, 2), prediction P = (0, 0, 2, 2): \mathrm{IoU} = 0, the enclosing box C = (0, 0, 5, 2) has area 10 and the union area 8, so \mathrm{GIoU} = 0 - (10 - 8)/10 = -0.2 , \qquad 1 - \mathrm{GIoU} = 1.2 .

Move P to (1, 0, 3, 2): the IoU is still 0, but now |C| = 8 equals the union, so \mathrm{GIoU} = 0 and the loss drops to 1. The loss 1 - \mathrm{IoU} equals 1 in both positions and gives no gradient.

For the offsets (0.4, -0.2, 2.0, 0.1), the smooth-L1 terms are 0.08, 0.02, 1.5 and 0.005: the large error counts 1.5, not 2.0^2/2 = 2.

Note — From detections to a scene graph A detector’s output — boxes, classes, scores — is the node set of a scene graph. Its edges carry spatial relations computed from the geometry: left of and above from image coordinates, in front of from depth (ch. 6) or from the camera model (ch. 1 and 5).

The image becomes a graph that a symbolic program or a relational GNN (Graph ML, ch. 5) can query. This is the perception front end of the Year 1 project Y1.5, where detection errors become missing or wrong nodes.

Note — Beyond massive supervision Pre-training on image-text pairs (CLIP: contrastive over 400 million pairs — see the Multimodal GenAI module, ch. 5) yields features that zero-shot classify by simple text-image similarity; “promptable” segmentation and conditional diffusion models (ibid., ch. 4-6) push the same idea into generation. Classical vision is not dead for all that: calibration, epipolar geometry, and ICP remain the foundations of metric systems — the subject of the next chapter.

Lab sheet: fine-tuning a pretrained detector (session 10)

About 90 minutes on a free GPU tier, in PyTorch and torchvision. On a laptop CPU, train for 2 epochs at a reduced image size and keep only the NMS ablation.

  1. Data. The Penn-Fudan pedestrian database (Wang, Shi, Song and Shen, ACCV 2007): 170 street images with 345 pedestrians, annotated with boxes and masks. Keep 120 images for training and 50 for testing, with a fixed seed.
  2. Model. torchvision’s Faster R-CNN with a ResNet-50 FPN backbone pretrained on COCO (fasterrcnn_resnet50_fpn); replace its box predictor by a two-class head (background, pedestrian).
  3. Training. First freeze the backbone and train the heads only, then unfreeze it. Use SGD with \eta = 0.005, momentum \beta = 0.9, weight decay 5\cdot10^{-4}, batches of 2 images, horizontal flips, 5 to 10 epochs. The model returns the losses of Definition 9.6 (classification and smooth-L1, for the proposal network and for the head): plot each one.
  4. Evaluation. AP@0.5 and mAP@[0.5:0.95] on the test images with torchmetrics.detection.MeanAveragePrecision; check the AP of one test image by hand with Definition 9.4 and Example 9.5.
  5. Ablations. NMS threshold 0.3, 0.5 and 0.7 (Definition 9.2); frozen against unfrozen backbone; 30 against 120 training images.
  6. Report, one page: the AP table, the loss curves, and three failure cases explained (occlusion, small or truncated pedestrians, duplicate boxes).

10. 3D point clouds: ICP and urban analysis

Mobile or airborne LiDAR, photogrammetry, RGB-D depth: the world also arrives as point clouds — millions of 3D points, possibly colored, with no topology. The questions become geometric: register two clouds, estimate normals, segment, classify.

Definition 10.1 — LiDAR: time-of-flight measurement A laser rangefinder emits a pulse and measures the echo: d = c\,\Delta t/2 with c \approx 3\times10^8 m/s. A precision of 2 cm requires timing to 2\times0.02/(3\times10^8) \approx 0.13 ns — and the echo is integrated over surfaces at varied incidence, hence the “comb” noise at edges. A mobile LiDAR (on a vehicle, IGN’s Stéréopolis for example) combines rangefinders, cameras, and an inertial/GNSS unit: fused odometry (Kalman filter) gives the trajectory, each position adds a “cap” of points to the global cloud; an urban network easily produces 10^9 points.

Proposition 10.2 — Neighborhoods, normals, complexities On a cloud of n points: the nearest neighbor is obtained with a kd-tree (or octree in 3D) in O(\log n) on average (construction O(n\log n)) versus O(n) by brute force (Definition 4.7): in 3D the dimensional caveat of Proposition 4.8 does not bite.

The local normal at point p is estimated by PCA of the neighborhood: the eigenvector associated with the smallest eigenvalue of the covariance matrix \sum_{q \in \mathcal{N}(p)} (q - \bar q)(q - \bar q)^\top (the residual variance to the tangent plane is minimal — a direct consequence of the Eckart-Young theorem of ch. 0). Cost per point: O(k) once the neighborhood is found.

Theorem 10.3 — ICP: optimal rigid transform (Kabsch) Given two paired sets \{p_i\}, \{q_i\}, i = 1..n, seeking R \in SO(3) and t minimizing \sum_i \|R\,p_i + t - q_i\|^2 has an exact solution: t = \bar q - R\bar p (centroids) and, setting H = \sum_i (p_i - \bar p)(q_i - \bar q)^\top = U\Lambda V^\top \quad \text{(SVD)},

Key result — Kabsch rotation R = V\,U^\top

(and R = V\,\mathrm{diag}(1, 1, \det(VU^\top))\,U^\top if \det(VU^\top) = -1, the “reflection” case).

Proof. The term in t is quadratic: setting the derivative to zero gives t = \bar q - R\bar p. Substituting, the sum becomes \sum_i \|R\,\tilde p_i - \tilde q_i\|^2 = \sum \|\tilde p_i\|^2 + \sum\|\tilde q_i\|^2 - 2\sum \tilde q_i^\top R\tilde p_i, where the \tilde{} denote centered points: minimizing amounts to maximizing \sum_i \tilde q_i^\top R \tilde p_i = \mathrm{tr}(RH).

Now \mathrm{tr}(RH) = \mathrm{tr}(R\,U\Lambda V^\top) = \mathrm{tr}(\underbrace{V^\top R U}_{=\,Z}\,\Lambda) = \sum_i Z_{ii}\, \lambda_i with Z orthogonal, so Z_{ii} \leq 1 and \lambda_i \geq 0 give \mathrm{tr}(RH) \leq \sum_i \lambda_i, attained for Z = I, i.e. R = VU^\top.

When \det(VU^\top) = -1, the maximizer Z = I would give a reflection; under the constraint \det R = +1 the best choice is Z = \mathrm{diag}(1, 1, -1), which sacrifices only the term of the smallest singular value \lambda_3. ∎

Proposition 10.4 — ICP: the algorithm and its local convergence ICP (Iterative Closest Point, Besl-McKay 1992) alternates:

  1. matching: each point of P is associated with its nearest neighbor in Q (kd-tree, O(n\log n));
  2. alignment: optimal rigid transform of the pairs (Theorem 10.3);
  3. application — until convergence.

Proof. The objective E(R, t) = \sum_i \|R p_i + t - \mathrm{nn}_Q(Rp_i + t)\|^2 decreases at every iteration: step (1) can only improve (or leave unchanged) each term by choosing the current nearest neighbor, and step (2) exactly minimizes the sum over these fixed matches. Combination of a decreasing sequence bounded below (by 0): convergence — to a local minimum, depending on the initialization. ∎

Remedies: coarse initialization (GPS, global descriptors, RANSAC over quadruplets), rejected matches (distance > quantile, incompatible normals), the point-to-plane variant (minimize distances to tangent planes — once linearized, it gives a more precise 6×6 least squares), or robust formulations: trimmed ICP, robust optimal transport (see below).

Example 10.5 — ICP and matching in Python

import numpy as np
from scipy.spatial import cKDTree

def best_rigid_transform(P, Q):            # theorem 10.3 (Kabsch)
    cp, cq = P.mean(0), Q.mean(0)
    H = (P - cp).T @ (Q - cq)              # 3x3
    U, S, Vt = np.linalg.svd(H)
    d = np.sign(np.linalg.det(Vt.T @ U.T))
    R = Vt.T @ np.diag([1, 1, d]) @ U.T
    return R, cq - R @ cp

def icp(P, Q, iters=50, tol=1e-7):
    tree = cKDTree(Q); R = np.eye(3); t = np.zeros(3); prev = np.inf
    for _ in range(iters):
        Pk = P @ R.T + t                          # current position of P
        d, idx = tree.query(Pk)                   # (1) matching
        Rk, tk = best_rigid_transform(Pk, Q[idx]) # (2) Kabsch increment
        R, t = Rk @ R, Rk @ t + tk                # (3) accumulation
        err = np.mean(d**2)
        if prev - err < tol: break
        prev = err
    return R, t, np.sqrt(err)

# synthetic test: 25-degree rotation + 1 cm noise
rng = np.random.default_rng(0)
src = rng.normal(size=(3000, 3)) * [10, 3, 1]     # elongated noisy "ground"
a = np.deg2rad(25)
Rt = np.array([[np.cos(a), -np.sin(a), 0],
               [np.sin(a),  np.cos(a), 0],
               [0, 0, 1]])
dst = src @ Rt.T + [2, -1, 0] + rng.normal(scale=.01, size=src.shape)
R, t, rms = icp(src, dst)
print("angle error (deg):", np.rad2deg(np.arccos((np.trace(R.T @ Rt)-1)/2)))
# ~0.002 deg here; on an isotropic blob ([10, 10, 1]) the same 25 deg start
# ends in a local minimum (Prop. 10.4): the shape gives ICP nothing to grip

Note — ICP and optimal transport Replacing “nearest neighbor” with a global matching that minimizes a transport cost means reformulating registration as an optimal transport problem (Computational Optimal Transport, Period 2: the transport problem in ch. 1, Wasserstein duality in ch. 2): the Wasserstein distance compares clouds as measures, not as labeled points — insensitive to differing densities, robust to noise with concave costs. This is the path explored by the recent literature on robust OT registration (RobOT, NeurIPS 2021; partial transport for incomplete clouds). The same formalism reappears to compare descriptor histograms or depth maps: a common language for ch. 6-10.

Proposition 10.6 — Representing a cloud for learning Three families of network inputs:

  • (i) volumes (voxelize into a 3D grid — 3D convolutions possible but cubic cost; sparse trees/octrees for the worst case);
  • (ii) raw points (PointNet: MLP per point + global max = symmetric function, permutation invariance; its successors add a local neighborhood);
  • (iii) range images (range images: project the cloud onto a spherical image whose every pixel encodes the distance — 2D CNNs then apply as-is, see LU-Net in ch. 11).

The choice is a memory/precision/speed trade-off — over 10^9 points, family (iii) is unbeatable and feeds the real-time systems of autonomous vehicles.

11. Research at IGN (Brédif): urban LiDAR

The module is taught by Mathieu Brédif, researcher at IGN (MATIS laboratory, ENSG) and professor at Université Gustave Eiffel. His work traverses exactly the program of the semester: mobile acquisition, registration, semantic analysis of urban clouds, and the handling of LiDAR sampling defects. Verified selection:

Note — The guiding thread One theme connects this work: processing massive 3D data with well-tuned 2D tools — range images, U-Net, inpainting — while respecting the geometry of the sensor. This is exactly the approach of ch. 1 to 10: model the formation (ch. 1), choose the representation (ch. 10), then apply the right machinery (ch. 9). The module’s project topics draw on the TerraMobilita benchmark and IGN’s open data.

Exercises

  1. ★ Camera (solved). Sensor 3000×2000 of 2.2 µm, focal length 24 mm. (a) Horizontal field of view? (b) Focal length in pixels? (c) How many point pairs for a homography, and why 4? (d) Does a pure rotation of the camera give a homography between views (justify)? Solution. (a) w = 6.6 mm, \mathrm{FOV} = 2\arctan(3.3/24) \approx 15.6^\circ. (b) f_x = 0.024/2.2\,\text{µm} \approx 10\,900 px. (c) 4 pairs: H has 8 dof (9 coefficients − 1 scale), each pair provides 2 independent equations (Prop. 5.3). (d) Yes: Theorem 5.2, case (ii) — it is even the only non-planar case that qualifies.

  2. ★ Convolution (solved). (a) Convolve [10, 12, 11, 40, 42] with the kernel [0.25,\,0.5,\,0.25] (replicated borders). (b) How many multiplications per pixel for a 5×5 Gaussian, direct then separable? (c) Why is a 3×3 box filter not an ideal smoother? Solution. (a) [10.5,\,11.25,\,18.5,\,33.25,\,41.5] — the jump 11→40 is smoothed over two samples. (b) 25 direct, 2\times5 = 10 separated (Prop. 2.2), ratio 2.5×. (c) its frequency response is a sinc (Def. 2.1 and the Signal Processing module, ch. 3): negative lobes create contrast reversals at high frequencies — the Gaussian has no rebound.

  3. ★ Lucas-Kanade (solved). Window of 4 pixels, measurements (I_x, I_y\,;\,I_t): (2, 1; 6), (4, 2; 10), (3, 1; 7), (5, 2; 12). Solve for the flow; compute the eigenvalues of the tensor; is the flow reliable? Propose two remedies.

    Solution. M = \begin{pmatrix}54 & 23\\ 23 & 10\end{pmatrix}, right-hand side -(133, 57)^\top. \det M = 11 — nearly singular: \lambda_1 \approx 63.8, \lambda_2 \approx 0.17. Cramer: u = v = -19/11 \approx -1.73.

    Reliability: no — \lambda_2 \ll \lambda_1 signals an edge (aperture problem, Thm 7.2); the uncertainty ellipse is very elongated: the flow component along the edge is poorly observed. Remedies: pyramid (large → small motion) and Gaussian weighting of the window; failing that, reject the pixel (\lambda_2 < \tau).

  4. ★ Stereo (solved). f = 721 px, B = 0.54 m. (a) Disparity of an object at 25 m, at 5 m? (b) Depth if d = 25 px? (c) Depth uncertainty at 25 m if the disparity is known to ±0.25 px? (d) Why double the baseline?

    Solution. (a) d = fB/Z: 15.6 px at 25 m; 77.9 px at 5 m. (b) Z = fB/d = 721\times0.54/25 \approx 15.6 m. (c) \Delta Z/Z = \Delta d/d = 0.25/15.6 \approx 1.6\,\% → ±0.4 m (Thm 6.3). (d) Z = fB/d: doubling B doubles d at equal depth, hence halves the relative error — at the price of a wider separation and increased occlusion areas between views.

  5. ★★ Harris in practice. Implement the structure tensor (Example 4.6), threshold R > 0.01\,R_{max}, display the corners on a photo; compare with cv2.cornerMinEigenVal. Rotate the image by 30° and measure the stability of the detection (Prop. 4.3). Hint: smoothing with \sigma \approx 1{-}2 before the Sobels; measure stability by the number of corners rematched within ±2 px.

  6. ★★ RANSAC. (a) Derive the formula for the number of draws N \geq \ln(1-p)/\ln(1-w^s) for an s-point estimator (independence of the draws).

    (b) Compute N for s = 4, w = 0.3, p = 0.999. (c) Adaptive RANSAC: how to stop before N draws?

    Hint: (a) failure probability 1-w^s per draw, independent ⇒ (1-w^s)^N \leq 1-p. (b) w^4 = 0.0081, N = 6.908/0.00813 \approx 850. (c) update w with the current best consensus and recompute N on the fly.

  7. ★★ ICP. Generate a noisy planar cloud, transform it (30° rotation), run the ICP of Example 10.5 from increasingly bad initializations; measure the basin of convergence. Test the point-to-plane variant on planes. Hint: plot the RMS error per iteration (log); the basin closes when matches cross the edges of the cloud — hence the value of rejecting distant pairs and of initial RANSAC.

  8. ★★ Segmentation, up close. On a photo, compare k-means on (a) RGB, (b) RGB + (x, y)/10, (c) Lab; choose k by the elbow method. Where do SLIC superpixels fit in a modern vision pipeline (ch. 8-9)? Hint: (b) forces spatial compactness — connected regions; (c) separates hue from luminance (Def. 1.5); connect to the Machine Learning module, ch. 7.

  9. ★★ Graph cut by hand (solved). Three pixels in a row, a – b – c. As in Example 8.5, the edge from s to a pixel carries the cost of the background label, and the edge to t the cost of the foreground label: 6 and 1 for pixel a, 3 and 2 for b, 1 and 5 for c. Both neighbour edges have \lambda B = 2.

    (a) Find a maximum flow by augmenting paths, and the minimum cut (Algorithm 8.4). (b) Check the result by listing the energies of Definition 8.3. (c) From which value of \lambda B does the whole row become foreground?

    Solution. (a) The paths s \to a \to t, s \to b \to t and s \to c \to t carry 1, 2 and 1; then s \to a \to b \to c \to t carries 2: the flow is 6.

    Then S = \{s, a, b\}: pixels a and b are foreground, c is background, and the cut 1 + 1 + 2 + 2 = 6 equals the flow.

    (b) The labelling (F, F, B) costs 1 + 2 + 1 + 2 = 6; (F, B, B) costs 7, (F, F, F) 8, (B, B, B) 10, and the four others more. (c) (F, F, F) costs 8 and (F, F, B) costs 4 + \lambda B: the whole row is foreground once \lambda B > 4.

Projects and assessment

The official assessment is “5 small classes (TD) + 1 project”, stated in the description of the 2026–2027 SynapseS sheet and in its section for the engineering degree; the LLGA section of the sheet displays no assessment of its own. The subjects below are proposals of these notes, not official rules. The exercises and the labs of the session plan match the five small classes, and one solo or group subject stands for the project; the sheet announces no written exam, so the exam below is only a proposal, for instance for a resit.

The projects exercise mainly O6 (vision, the visual side of the multimodal objective), O7 (complete pipelines on real benchmarks, checked against OpenCV, COLMAP or torchvision) and O1 (SVD, least squares and CNN training), with O4 and O5 in the graph-cut, LiDAR-graph and scene-graph subjects.

Solo projects

  1. [Solo · ≈ 20 h] Panorama stitcher from scratch. When does a handheld panorama break the homography model of Theorem 5.2, and how many RANSAC draws does matching really need?
    • Work: Harris and SIFT matching with Lowe’s ratio test, Hartley-normalized DLT, adaptive RANSAC whose number of draws is measured against Proposition 5.4, inverse warping with bilinear interpolation, and feathered blending; the method of Brown and Lowe (“Automatic Panoramic Image Stitching using Invariant Features”, IJCV 2007).
    • Data: the 59 viewpoint sequences of HPatches (Balntas, Lenc, Vedaldi and Mikolajczyk, CVPR 2017), which come with ground-truth homographies; then your own sequences, on a tripod (pure rotation), of a planar facade, and handheld with parallax — the two cases of Theorem 5.2 and one failure.
    • Success criterion: mean corner error of the estimated homographies under 3 px on most HPatches viewpoint pairs; measured draws compared with Proposition 5.4; seams and ghosting compared with cv2.Stitcher and explained.
    • Deliverables: code, a 4–6 page report, a 10-minute talk; chapters 2, 4 and 5.
  2. [Solo · ≈ 20 h] Paper study: how robust is ICP, and does optimal transport help? (Besl and McKay, 1992; Shen, Feydy et al., NeurIPS 2021). How wide is the basin of convergence of point-to-point, point-to-plane and trimmed ICP, and does a soft transport matching widen it?
    • Work: starting from Example 10.5, map the success rate against the initial rotation, the noise, the overlap and density changes; add an entropic-OT (Sinkhorn) soft matching in the spirit of the RobOT paper, computed with the POT or GeomLoss library, and a RANSAC initialization on Open3D’s FPFH features.
    • Data: the Stanford Bunny scans bun000 and bun045 of the Stanford 3D Scanning Repository (partial overlap), and the synthetic clouds of Example 10.5.
    • Success criterion: success-rate curves (final rotation error under 2°) against the initial angle for each method, with the RMS per iteration and the time per run; the OT variant compared at equal time budget.
    • Deliverables: code, report, talk; chapters 0 and 10. It leads to Computational Optimal Transport, ch. 3 (Sinkhorn) and to the ICP of Shapes, ch. 4.
  3. [Solo · ≈ 20 h] Graph cuts against learned segmentation. With the same user input, how close does an interactive graph cut get to a pretrained promptable segmenter?
    • Work: Boykov-Jolly segmentation (Definition 8.3) with Gaussian B_{pq} and colour-histogram terminal costs, solved with the PyMaxflow library (Boykov-Kolmogorov); a sweep of the Potts weight \lambda; k-means and SLIC baselines; a normalized cut of the same pixel graph on downsampled images; Segment Anything (Kirillov et al., ICCV 2023) prompted with the same box.
    • Data: the GrabCut dataset (Rother, Kolmogorov and Blake, SIGGRAPH 2004): 50 images with ground-truth masks and the user trimaps of the paper.
    • Success criterion: mean IoU over the 50 images for each method with identical user input; the effect of \lambda explained with Example 8.5.
    • Deliverables: code, report, talk; chapters 8 and 9. The normalized cut is the spectral clustering of Graph ML, ch. 4.

Group projects

  1. [Group of 3 · ≈ 30 h each] From two views to multi-view stereo and novel views. How close can a pipeline written from the chapters get to COLMAP, and where does it break?
    • Work: calibrate a phone camera (Zhang’s checkerboard, ch. 1); normalized 8-point algorithm with RANSAC, decomposition of E and the chirality test (Proposition 6.2); triangulation and incremental SfM with bundle adjustment by scipy.optimize.least_squares (Definition 6.5); plane-sweep NCC on 5–10 views (Definition 6.8); interpolated views (Example 6.10) and, as a stretch, a 3D Gaussian splatting fit from the recovered poses.
    • Data: your own captures, then one scene of the ETH3D high-resolution multi-view benchmark (Schöps et al., CVPR 2017), which provides laser-scan ground truth.
    • Split: calibration and two-view geometry; SfM and bundle adjustment; multi-view stereo and rendering.
    • Success criterion: camera rotations within 2° of COLMAP’s; accuracy and completeness of the fused cloud against the ETH3D scan at a 5 cm tolerance; disocclusion holes shown and explained.
    • Deliverables: code, an 8–10 page joint report, a 20-minute talk; chapters 1, 5 and 6.
  2. [Group of 3 · ≈ 30 h each] Urban LiDAR segmentation: range image, points or graph? Which representation of Proposition 10.6 gives the best accuracy per unit of memory and time on street scans?
    • Work: three pipelines under the same budget — (i) a range image and a U-Net in the style of LU-Net (ch. 11); (ii) PointNet on raw points; (iii) a GNN over the k-nearest-neighbour graph, with PCA normals as node features (Proposition 10.2).
    • Data: a subset of SemanticKITTI (Behley et al., ICCV 2019), two training sequences and the validation sequence 08; as a stretch, the TerraMobilita/iQmulus benchmark (Vallet et al., 2015) of ch. 11.
    • Split: one pipeline per member, with shared data loading and evaluation.
    • Success criterion: mIoU on the held-out sequence, memory and latency per scan for the three pipelines; an analysis of the errors in occluded areas (ch. 11).
    • Deliverables: code, joint report, talk; chapters 9–11. Pipeline (iii) is the message passing of Graph ML, ch. 5.
  3. [Group of 3 · ≈ 30 h each] Scene graphs from detections, the perception front end of Y1.5. How much does detection error degrade the scene graph, and the answers computed on it?
    • Work: fine-tune a detector with attribute heads (colour, shape, material, size) as in the lab sheet of ch. 9; build the scene graph of the Note in ch. 9, with left of and behind from the box positions; answer a few CLEVR question families with a symbolic program executor, on gold and on predicted graphs.
    • Data: CLEVR (Johnson et al., CVPR 2017), a subset of about 10,000 training and 2,000 validation renders (of 70,000 and 15,000), with full scene annotations and question programs.
    • Split: detector and attributes; scene-graph builder and its metrics; question executor and evaluation.
    • Success criterion: AP@0.5 per attribute class; edge precision and recall of the predicted scene graphs against the annotations; question accuracy on gold against predicted graphs, as a function of the detection threshold.
    • Deliverables: code, joint report, talk; chapters 1, 5 and 9. It is the first milestone of the Year 1 project Y1.5 and feeds the relational GNNs of Graph ML, ch. 5.

Written exam (proposal)

Two hours, one handwritten A4 sheet allowed, a simple calculator allowed; four exercises.

  1. Question (5 points). Explain why the Harris response is invariant to a rotation of the image but not to a change of scale. List the steps by which SIFT obtains scale and rotation invariance, then state Lowe’s edge-rejection test and say what it rejects.
    • Expected: M averages \nabla I\,\nabla I^\top, and a rotation maps it to RMR^\top: same eigenvalues, same response (Proposition 4.3). A zoom changes which pixels fall in the window, so a corner at one scale looks like an edge or a flat area at another.
    • SIFT: extrema of the DoG in (x, y, \sigma) for scale; the dominant gradient orientation for rotation; a 4\times4\times8 histogram, normalized and clipped at 0.2, for illumination.
    • Edge test: keep a point only if \det H > 0 and \mathrm{tr}(H)^2/\det H < (r+1)^2/r, with r = 10; it rejects edge-like points, whose principal curvatures differ by a factor above 10.
  2. Question (5 points). A rectified stereo rig has f = 700 px and B = 0.5 m. (a) Give the depth of a point with disparity 14 px, and its uncertainty if the disparity is known to ±0.5 px. (b) F is estimated by RANSAC on 8-point samples with 50% inliers: how many draws give 99% confidence? And with the 7-point algorithm?
    • Expected: Z = fB/d = 350/14 = 25 m, and \Delta Z \approx Z^2\Delta d/(fB) \approx 0.89 m, that is 3.6% (Example 6.4).
    • By Proposition 5.4, N \geq \frac{\ln(0.01)}{\ln(1 - 0.5^8)} = \frac{4.605}{0.00391} \approx 1177 draws; with 7 points, 4.605/0.00784 \approx 588: one point fewer per sample halves the number of draws at this inlier rate.
  3. Question (5 points). Let p_i, q_i (i = 1, \dots, n) be paired points of \mathbb{R}^3, with centred versions \tilde p_i = p_i - \bar p and \tilde q_i = q_i - \bar q, and consider \min_{R \in SO(3),\ t \in \mathbb{R}^3} \ \sum_i \|R p_i + t - q_i\|^2, \qquad H = \sum_i \tilde p_i \tilde q_i^\top = U\Lambda V^\top . Prove that the optimal translation is t = \bar q - R\bar p, that the best rotation then maximizes \mathrm{tr}(RH), and that it is R = VU^\top when \det(VU^\top) = 1.
    • Expected: the gradient in t, 2\sum_i (R p_i + t - q_i), vanishes at t = \bar q - R\bar p.
    • Substituting, the cost becomes \sum_i\|\tilde p_i\|^2 + \sum_i\|\tilde q_i\|^2 - 2\sum_i \tilde q_i^\top R\,\tilde p_i , \qquad \sum_i \tilde q_i^\top R\,\tilde p_i = \mathrm{tr}(RH) .
    • With Z = V^\top R U, which is orthogonal, \mathrm{tr}(RU\Lambda V^\top) = \mathrm{tr}(Z\Lambda) = \sum_i Z_{ii}\lambda_i \leq \sum_i \lambda_i , since Z_{ii} \leq 1 and \lambda_i \geq 0. Equality holds at Z = I, that is R = VU^\top, a rotation since its determinant is 1 (Theorem 10.3).
  4. Question (5 points). One class, boxes written (x_1, y_1, x_2, y_2). Two ground truths and four detections, sorted by decreasing score: G_1 = (0, 0, 4, 4),\ G_2 = (10, 0, 14, 4); \qquad D_1 = (0, 0, 4, 4),\ D_2 = (1, 0, 5, 4),\ D_3 = (10, 2, 14, 6),\ D_4 = (11, 0, 15, 4).
    1. Compute the IoU of D_2 with G_1 and of D_3, D_4 with G_2. (b) Which detections survive NMS at 0.5? (c) Give the AP at \tau = 0.5, without and with NMS.
    • Expected: (a) 12/20 = 0.6; 8/24 \approx 0.33; 12/20 = 0.6.
    • (b) \mathrm{IoU}(D_1, D_2) = 0.6 > 0.5 removes D_2; \mathrm{IoU}(D_3, D_4) = 6/26 \approx 0.23 keeps both. D_1, D_3 and D_4 survive.
    • (c) Without NMS the verdicts are TP, FP (duplicate), FP, TP: precision 1 up to recall 0.5, then 0.5 at recall 1, so \mathrm{AP} = 0.5 + 0.25 = 0.75. With NMS they are TP, FP, TP and \mathrm{AP} = 0.5 + 0.5 \times 0.67 \approx 0.83 (Example 9.5).

Grading rubric (proposal)

Criterion Weight What earns the marks
Model and question 15 % the camera, scene and noise assumptions stated, and the question tied to a statement of the chapters (Theorem 5.2, Theorem 6.3, Proposition 10.4)
Correct implementation 25 % code written from the definitions and checked against a reference (OpenCV, COLMAP, torchvision, PyMaxflow) with a stated tolerance
Experimental protocol 20 % held-out images or sequences, several seeds or initializations, honest baselines, no tuning on the test set
Analysis tied to the course 25 % each result, failures included, explained by the course: aperture problem, local minima of ICP or k-means, disocclusion, scale of the error Z^2\Delta d/(fB)
Communication 15 % figures that show the images and the errors, a talk on time, honest limits

References