The Evolution of Computer Vision: From Classical Methods to Deep Learning
The story of modern computer vision is a story of paradigm shifts—from hand-crafted rules to learned representations, from brittle feature detectors to robust hierarchical models, from academic curiosities to technologies that power billions of devices. To understand why deep learning dominates the field today, we must first appreciate the elegant, yet ultimately limited, classical methods that preceded it. This chapter traces that evolutionary trajectory, not merely as a historical exercise, but to illuminate the fundamental problems that deep learning was engineered to solve. We will dissect the mechanics of SIFT and HOG, analyze the architectural innovations of AlexNet, VGG, and ResNet, and formally define the core tasks—classification, detection, segmentation—that serve as the bedrock for all subsequent discussion. By the end, the reader will understand why the convolutional neural network (CNN) became the universal function approximator for visual data and will have a clear map of the advanced terrain this book will explore.
1.1 The Classical Era: Hand-Crafted Features and the Quest for Invariance
Before the rise of data-driven learning, computer vision relied on a pipeline that was, in hindsight, remarkably analogous to traditional software engineering: perception → hand-crafted feature extraction → machine learning classifier. The central, unsolved problem was feature design. How does one transform raw pixel intensities (a matrix of numbers) into a representation that is simultaneously discriminative (different objects look different) and invariant (the same object looks the same under varying conditions like rotation, scale, illumination, and viewpoint)? For decades, the brightest minds in the field crafted clever algorithms to answer this question, producing a pantheon of feature descriptors that are still studied today for their profound insight into visual structure.
1.1.1 Scale-Invariant Feature Transform (SIFT): The Gold Standard
David Lowe's 1999 paper, *Object Recognition from Local Scale-Invariant Features*, and its 2004 journal version, stands as one of the most influential works in the pre-deep learning era. SIFT was designed for object instance recognition—matching specific real-world objects across different images, a task fundamental to 3D reconstruction (Structure from Motion), image stitching, and robotics.
The core innovation of SIFT is its complete invariance to scale, rotation, and partial invariance to illumination and viewpoint. It achieves this through a meticulously designed multi-stage pipeline:
1. Scale-Space Extrema Detection (Building Scale Invariance): SIFT constructs a scale space by repeatedly convolving the input image with Gaussian kernels of increasing variance ($\sigma$). This creates a pyramid of increasingly blurred images. The difference between adjacent Gaussian-blurred images yields the Difference-of-Gaussians (DoG) pyramid. Keypoints (potential features) are identified as local extrema (maxima or minima) in this 3D DoG space (x, y, scale). This process inherently finds features that are stable across scales, as an extrema in scale-space corresponds to a characteristic scale of a structure in the image.
```mermaid graph TD A[Original Image] --> B[Gaussian Blur σ₁] A --> C[Gaussian Blur σ₂] B --> D[DoG₁ = G₂ - G₁] C --> D D --> E[Find Local Extrema<br/>in 3D Space (x,y,σ)] E --> F[Candidate Keypoints] ```
2. Keypoint Localization (Rejecting Unstable Points): The candidate extrema are then fit to a 3D quadratic function to precisely locate the keypoint and discard those with low contrast (unstable to noise) or those located on edges (poorly localized along the edge direction). The latter is detected using the Hessian matrix's principal curvatures; points where one curvature is much larger than the other are rejected.
3. Orientation Assignment (Achieving Rotation Invariance): For each remaining keypoint, a local neighborhood is analyzed. The gradient magnitude and direction are computed for all pixels in this region. An orientation histogram (36 bins covering 360°) is created, weighted by gradient magnitude and a Gaussian window centered on the keypoint. The peak(s) in this histogram define the keypoint's dominant orientation(s). All subsequent operations are performed relative to this orientation, achieving rotation invariance.
4. Keypoint Descriptor (The Final Representation): A $16 \times 16$ window around the keypoint (rotated to its assigned orientation) is divided into $4 \times 4$ sub-regions. For each sub-region, an 8-bin orientation histogram is computed, again weighted by gradient magnitude and a Gaussian window. This yields a $4 \times 4 \times 8 = 128$-dimensional descriptor vector. This descriptor is normalized to unit length to provide partial illumination invariance, and thresholded to reduce the influence of large gradient magnitudes (non-linear illumination changes).
Practical Impact & Limitation: SIFT descriptors were the de facto standard for matching for over a decade. They enabled robust image alignment for panorama stitching and were the workhorse of early 3D reconstruction systems like VisualSfM. However, SIFT is not a learning method. It is a fixed, deterministic algorithm. Its invariance properties, while impressive, are brittle compared to what a large neural network can learn. It is also computationally expensive and, crucially, not differentiable. You cannot backpropagate a loss through a SIFT extractor to improve the features for a specific downstream task like classification. This fundamental limitation made it incompatible with the end-to-end training paradigm that deep learning would later champion.
1.1.2 Histogram of Oriented Gradients (HOG): The Workhorse of Detection
While SIFT targeted sparse, distinctive features for matching, Navneet Dalal and Bill Triggs' 2005 paper introduced Histogram of Oriented Gradients (HOG) for dense, local shape representation and pedestrian detection. HOG became the backbone of classical object detection pipelines, most famously as the feature input to a Support Vector Machine (SVM) in the Deformable Part Model (DPM) by Felzenszwalb et al., which won the PASCAL VOC detection challenge multiple times.
The HOG descriptor operates on a dense grid over the image, capturing the distribution of local gradient orientations:
1. Gradient Computation: The image is first pre-processed, often with a mild Gaussian smoothing. Then, the horizontal and vertical image gradients ($G_x, G_y$) are computed using a simple $[-1, 0, 1]$ filter or more sophisticated derivatives like the Sobel operator. The gradient magnitude $m = \sqrt{G_x^2 + G_y^2}$ and orientation $\theta = \arctan(G_y/G_x)$ are calculated for each pixel.
2. Spatial Binning: The image is divided into small connected cells (e.g., $8 \times 8$ pixels). For each cell, a histogram of gradient orientations (e.g., 9 bins covering 0-180°) is built. Each pixel's gradient magnitude votes into the appropriate orientation bin. This creates a per-cell histogram.
3. Block Normalization (Crucial for Invariance): Groups of spatially adjacent cells (e.g., $2 \times 2$ cells) form a block. The histograms of all cells within a block are concatenated into a single vector, which is then normalized using schemes like L2-norm, L2-Hys (clipping), or L1-sqrt. Normalization across blocks is key to achieving invariance to changes in illumination and contrast, as it ensures the descriptor's energy is distributed consistently.
4. Descriptor Formation: The normalized block vectors from across the entire detection window (e.g., $64 \times 128$ pixels for pedestrian detection) are concatenated to form the final, high-dimensional HOG descriptor. For the classic pedestrian example, this results in a descriptor of thousands of dimensions.
**Why HOG Worked for Det