Chapter 1: Introduction to Computer Vision
Understanding the fundamentals of computer vision: what it is, how digital images work, historical context, and the mathematical foundations you'll need throughout this course.
- Topics
- 4
- Videos
- 4
- Min read
- 30
Chapter Overview
Welcome to Computer Vision! This chapter establishes the foundation for everything that follows.
What is this chapter about? We'll answer the fundamental questions: What is computer vision? Why is it hard? How do computers see images? This context is essential before diving into algorithms.
Why does this matter? Understanding the challenges and capabilities of computer vision helps you choose the right approach for real problems. Knowing how images are represented lets you manipulate them effectively.
How the topics connect: We start by defining computer vision and its applications—understanding what problems we're solving. Then we dive into digital images—how they're represented as arrays of numbers. We trace the history of the field to understand why modern approaches work. Finally, we cover key mathematical concepts that appear throughout the course.
Chapter Roadmap
Click any topic to jump in
What is CV?
The vision pipeline, applications, and core challenges — why making computers see is fundamentally hard.
Pixels and coordinate systems
Digital Images & Pixels
Pixel intensity, resolution, color models — images as mathematical functions on a grid.
Image Coordinates
Row-major ordering, coordinate transforms, and pixel center conventions.
Math Notation for CV
Vectors, matrices, homogeneous coordinates — the mathematical language of computer vision.
Topics
4 topics in this chapter
Hand a three-year-old a photograph and they will tell you there is a dog behind the sofa, that it is the same dog as yesterday, and that it is probably wet. Hand a computer the same photograph and it receives a grid of several million numbers, with nothing marking which of them belong together, let alone that they form a dog. No number is labelled edge, fur or behind. That gap — effortless for you, still only partly closed after fifty years of research — is what this topic is about. Chapter 0, Mathematical Foundations, supplied the machinery: keep Vectors and Vector Operations and Matrices and Transformations close, because an image is about to turn into a matrix. We work through three things, in order. First the pipeline every vision system runs, from acquisition to decision, so you have a skeleton to hang the rest of the course on. Then the applications that pipeline serves, from surgical guidance to cashierless stores. Finally the challenges — viewpoint, lighting, occlusion, and the fact that a 2D image is a lossy shadow of a 3D world — which explain why each stage of the pipeline exists at all.
Definition
Computer Vision is a field of artificial intelligence that enables computers to interpret and understand visual information from the world, such as images and videos. Just as humans use their eyes and brain to see and understand their surroundings, computer vision systems use cameras and algorithms to perform similar tasks.
The goal of computer vision is to automate tasks that the human visual system can do—recognizing objects, understanding scenes, tracking motion, and making decisions based on visual input.
In this topic
- 1The Vision Pipeline
- 2Key Application Areas
- 3Challenges in Computer Vision
The Vision Pipeline
Computer vision systems typically follow a processing pipeline:
- Image Acquisition: Capturing images using cameras or sensors
- Preprocessing: Cleaning up images (noise reduction, contrast enhancement)
- Feature Extraction: Identifying important patterns (edges, corners, textures)
- Analysis/Recognition: Understanding what's in the image
- Decision/Action: Taking action based on the analysis
Classical vs Deep Learning Pipelines:
- Classical: Hand-designed features (SIFT, HOG) → classifier (SVM)
- Deep Learning: End-to-end learned features and classification via CNNs
Real-time Considerations: Each stage adds latency. For 30fps video, the entire pipeline must complete in ~33ms. This drives architectural choices like running detection on keyframes and tracking between them.
Think of it like how you read a sign: your eyes capture light (acquisition), your brain filters out irrelevant details (preprocessing), recognizes letter shapes (feature extraction), understands the word (analysis), and you act on it (decision).
Each pipeline stage is a function composition: . The output of one stage becomes the input to the next. Classical pipelines use hand-crafted functions; deep learning replaces the middle stages with a single learned function parameterized by neural network weights.
A face recognition system captures a photo, detects the face, extracts features, and matches to a database. Which pipeline stage handles each step?
Key Application Areas
Computer vision is used across virtually every industry:
Transportation & Mobility: • Autonomous Vehicles: Perception for self-driving (Tesla, Waymo) • Traffic Monitoring: Congestion analysis, incident detection
Healthcare: • Medical Imaging: Detecting tumors, diabetic retinopathy screening • Surgical Robotics: Visual guidance for minimally invasive procedures
Commerce & Retail: • Visual Search: Find products by photo (Google Lens, Pinterest) • Cashierless Stores: Amazon Go uses CV for checkout-free shopping
Security: • Facial Recognition: Access control, surveillance • Anomaly Detection: Identifying unusual behavior in video feeds
Creative & Entertainment: • AR/VR: Spatial mapping, object placement, hand tracking • Film VFX: Motion capture, rotoscoping, face replacement
Industry 4.0: • Quality Control: Automated defect detection on production lines • Robotics: Pick-and-place, bin picking with vision guidance
Most CV applications reduce to a few core mathematical problems: classification maps an image to a label vector , detection adds spatial coordinates , and segmentation produces a per-pixel label map . Recognizing which formulation fits your task is the first step.
Classify these CV tasks by application area: (1) Detecting scratches on smartphone screens, (2) Adding virtual furniture to room photos, (3) Counting cells in a microscope image.
Challenges in Computer Vision
Why is computer vision hard? The challenges fall into several categories:
Appearance Variation: • Viewpoint: Objects look different from different angles • Scale: Objects can be near or far from the camera • Illumination: Lighting changes appearance dramatically • Deformation: Non-rigid objects change shape (people, animals)
Scene Complexity: • Occlusion: Objects can be partially hidden behind other objects • Background Clutter: Complex backgrounds make object detection difficult • Multiple Instances: Crowded scenes with many overlapping objects
Semantic Gaps: • Intra-class Variation: Objects in the same category look very different (all types of chairs) • Fine-grained Recognition: Distinguishing similar categories (dog breeds, bird species) • Context Understanding: A stop sign means different things in different contexts
The Fundamental Problem: Images are 2D projections of a 3D world. We lose depth information, and many 3D scenes can produce the same 2D image. Humans handle these ambiguities using context and prior knowledge—teaching computers to do so remains an active research challenge.
The core difficulty is the many-to-one nature of projection: infinitely many 3D scenes produce the same 2D image. Mathematically, the mapping is not injective — recovering 3D from 2D is an ill-posed inverse problem requiring priors or additional constraints.
A pedestrian detection system fails when a person is partly behind a parked car. Which challenge category is this?
Theory Exercise
Problem:
A self-driving car needs to stop at a red traffic light. List at least 5 challenges the computer vision system might face when trying to detect the traffic light, and briefly explain why each is a challenge.
Hints:
- Think about different weather conditions
- Consider different times of day
- What about other objects that might be red?
Related Problems on PixelBank
Suppose you want to brighten a photograph. What, exactly, do you add to? The previous topic, What is Computer Vision?, sketched a pipeline in which images flow from acquisition through preprocessing into analysis, but left the thing flowing between those stages abstract. Until you can say what an image is in memory — how many numbers, in what range, arranged how — you cannot write a line of code that touches one, cannot predict whether a dataset will fit in RAM, and cannot explain why a smooth sky gradient turns into visible stripes. This topic makes the image concrete in four steps, each resting on the one before. We start with a single pixel and its bit depth, which fixes the range of values available at all. Resolution and file size follow, since both are that pixel count multiplied out. Third comes the step that pays off for the rest of the course: treating the whole image as a function , so filtering, convolution and frequency analysis become ordinary mathematics. We close on colour models — RGB, HSV, LAB, YCbCr — and why segmentation code so often converts away from RGB first.
Definition
A digital image is a numerical representation of a visual scene, stored as a 2D array (matrix) of discrete picture elements called pixels. Each pixel contains intensity or color information at a specific location in the image.
Think of a digital image like a mosaic—when you look closely, you see individual tiles (pixels), but from a distance, they blend together to form a complete picture. The more tiles you have (higher resolution), the smoother and more detailed the image appears.
In this topic
- 1Pixel Intensity and Bit Depth
- 2Image Resolution and Size
- 3Image as a Mathematical Function
- 4Color Models
Pixel Intensity and Bit Depth
Each pixel stores an intensity value. The bit depth determines how many unique values are possible:
• 1-bit: Binary image (0 = black, 1 = white) — only 2 values • 8-bit: Grayscale (0 = black, 255 = white) — 256 values, most common • 16-bit: High dynamic range — 65,536 values, used in scientific imaging • 32-bit float: HDR and computational photography — continuous values
For color images, each pixel typically has 3 channels (Red, Green, Blue), each with 8 bits, giving 24 bits per pixel and over 16 million possible colors ().
Quantization and Banding: When bit depth is too low, you see visible "steps" in gradients called banding. This is why video uses 10-bit color (1024 levels) for professional work.
Dynamic Range: The ratio between brightest and darkest values a sensor can capture. HDR imaging combines multiple exposures to exceed sensor limits.
The human eye can distinguish about 10 million colors, so 24-bit color is sufficient for most display applications.
Bit depth defines the precision of the quantization function . Quantization error where . Doubling bit depth halves quantization noise, which is why medical imaging uses 12-16 bits.
A medical scanner uses 12-bit depth. How many unique intensity levels can it capture?
Image Resolution and Size
where = width, = height, = channels, = bits per channel
Resolution refers to the number of pixels in an image, typically expressed as width × height:
• HD: 1920 × 1080 = 2,073,600 pixels (about 2 megapixels) • 4K UHD: 3840 × 2160 = 8,294,400 pixels (about 8.3 megapixels) • 8K: 7680 × 4320 = 33.2 megapixels • Smartphone: Often 12-200 megapixels
Spatial vs Angular Resolution: Spatial resolution is pixel count. Angular resolution is pixels per degree of view—what matters for perceived sharpness.
Aspect Ratio: Width/height ratio. Common ratios: 4:3 (classic), 16:9 (widescreen), 1:1 (square for social media).
The file size of an uncompressed image:
Compression: JPEG achieves 10:1-20:1 compression with minimal visible quality loss. PNG is lossless. WebP offers both options with better compression than either.
Resolution determines the sampling density on the image plane. By Nyquist, a resolution of can represent spatial frequencies up to and cycles. Uncompressed storage is exactly bytes — a linear function of pixel count.
Calculate the uncompressed size of a 1920×1080 RGB image with 8 bits per channel.
Image as a Mathematical Function
where for grayscale, for RGB
We can represent an image mathematically as a function that maps 2D coordinates to intensity values:
• Grayscale: — a single value at each location • Color (RGB): — three values at each location
This mathematical representation is powerful because it lets us:
- Apply mathematical operations (add, subtract, multiply images)
- Perform transformations (rotate, scale, translate)
- Apply filters and convolutions
- Analyze statistical properties (mean, variance, histograms)
Continuous vs Discrete: The real world is continuous, but digital images are discrete samples. The Nyquist-Shannon sampling theorem tells us we need at least 2 samples per cycle of the highest frequency to avoid aliasing artifacts.
Images as Tensors: In deep learning, images are represented as 3D tensors with shape (Height, Width, Channels) or (Channels, Height, Width) depending on the framework. A batch of images adds a fourth dimension: (Batch, C, H, W).
Treating images as functions lets us apply the full toolkit of analysis. Addition blends images, convolution applies filters, the Fourier transform reveals frequency content. This functional view is why linear algebra and signal processing are the mathematical backbone of CV.
An image has . After brightening by adding 30, what is the new value? What if the result exceeds 255?
Color Models
Different ways to represent color in images serve different purposes:
RGB (Red, Green, Blue): • Additive color model (mixing light) • Each channel 0-255, (0,0,0) = black, (255,255,255) = white • Used by displays, cameras, most image processing • Not perceptually uniform—equal changes in RGB don't appear equal to humans
HSV/HSL (Hue, Saturation, Value/Lightness): • More intuitive for humans • Hue = color type (0-360°), Saturation = color purity, Value = brightness • Useful for color-based segmentation and adjustments
LAB (Lightness, A, B): • Designed to be perceptually uniform • L = lightness, A = green-red, B = blue-yellow • Used for color difference calculations and color correction
YCbCr: • Separates luminance (Y) from chrominance (Cb, Cr) • Used in JPEG and video compression—humans are less sensitive to color detail
Grayscale Conversion: These weights reflect human eye sensitivity (most sensitive to green, least to blue).
Color spaces are coordinate transforms on . RGB to grayscale is a linear projection where weights by human cone sensitivity. RGB to HSV is a nonlinear transform that decouples chrominance from luminance, making color-based thresholding axis-aligned and therefore simpler.
Convert RGB (100, 200, 50) to grayscale using the weighted formula.
Theory Exercise
Problem:
A smartphone camera captures a 4032 × 3024 pixel image in RAW format with 12 bits per color channel (RGB). Calculate:
a) The total number of pixels b) The uncompressed file size in megabytes (MB) c) If the same image is stored as a standard 8-bit JPEG with 10:1 compression, what would be the approximate file size?
Hints:
- 1 MB = 1,000,000 bytes (or 1,048,576 for binary MB)
- RAW files store all bits without compression
- For part (c), first calculate the 8-bit uncompressed size, then apply compression
Related Problems on PixelBank
You write image[100, 50] expecting the pixel a hundred columns from the left, and get the one a hundred rows down instead. Your detector reports a feature near the top of the picture and your plotting library draws it near the bottom. Neither is a subtle algorithmic failure; both come from a convention that computer vision quietly inverted. Every diagram in Chapter 0, Mathematical Foundations, put the origin at the bottom-left with increasing upward. Images do the opposite: the origin sits at the top-left, counts rows downward, and arrays are indexed — the reverse order of the notation the previous topic, Digital Images and Pixels, introduced. We begin with that row-major memory layout and the offset it implies, because it explains both the index order and why scanning an image along the wrong axis is slow. From there we convert between image, centred, normalized-device and UV coordinates. We finish on the half-pixel question — whether an integer coordinate names a pixel's centre or its corner — which is the root of align_corners bugs in every resampling library you will use.
Definition
The image coordinate system defines how we reference pixel locations in a digital image. Unlike the standard Cartesian coordinate system used in mathematics, images use a coordinate system where:
• The origin (0, 0) is at the top-left corner of the image • The x-axis increases to the right (column index) • The y-axis increases downward (row index)
This convention comes from how images are stored in memory (row by row, top to bottom) and how CRT monitors drew images (scanning left-to-right, top-to-bottom).
In this topic
- 1Row-Major vs Column-Major Ordering
- 2Coordinate Transformations
- 3Pixel Centers vs Corners
Row-Major vs Column-Major Ordering
For image[y, x] in a width- image
Images are typically stored in row-major order in memory: all pixels of row 0 first, then row 1, etc. This affects how we index arrays:
NumPy/Python convention: image[row, column] or image[y, x]
OpenCV convention: Same as NumPy—image[y, x] but functions use (x, y) order!
MATLAB convention: image(row, column) — 1-indexed!
PyTorch/TensorFlow: Usually (batch, channels, height, width) or (batch, height, width, channels)
This can be confusing because in mathematics we typically write with first, but in image arrays we access [y, x] with first.
Performance Implications: Accessing pixels in row-major order (iterating over x in inner loop) is faster due to CPU cache locality. Accessing column-by-column causes cache misses.
Memory layout: For an image with width , pixel at is at memory index:
In row-major layout, pixel maps to memory offset , making horizontal scans cache-friendly. Column-major uses offset . This matters because modern CPUs load data in cache lines — accessing pixels along the wrong axis causes cache misses that can slow convolutions by 10x.
In a 640-wide image, what is the memory index of pixel at position ?
Coordinate Transformations
Sometimes you need to convert between different coordinate systems:
Image coords → Centered coords (origin at image center):
Note: We flip to match mathematical convention where increases upward.
Centered coords → Image coords:
Normalized Device Coordinates (NDC): Many graphics APIs use coordinates in [-1, 1] or [0, 1] range:
UV Coordinates: Texture mapping uses coordinates in [0, 1] range:
These transformations are essential for rotation around image center, camera projection, and texture mapping.
Mapping between coordinate systems is an affine transform . The (row, col) to (x, y) swap is a specific case: , . Getting this wrong introduces transposition bugs — one of the most common errors in CV code, especially when mixing OpenCV (row, col) with matplotlib (x, y).
Convert pixel to centered coordinates in a 200×100 image.
Pixel Centers vs Corners
An important subtlety: does coordinate refer to the pixel's center or its top-left corner?
Integer coordinates at pixel centers (OpenCV, most CV libraries): • Pixel 0 spans from -0.5 to +0.5 • Pixel 1 spans from +0.5 to +1.5 • Pixel (0,0) is centered at exactly (0,0)
Integer coordinates at pixel corners (some graphics APIs): • Pixel 0 spans from 0 to 1 • Pixel 1 spans from 1 to 2 • Pixel (0,0) is centered at (0.5, 0.5)
Why This Matters: • Interpolation: Sub-pixel values require knowing pixel boundaries • Geometric Transformations: Half-pixel offsets accumulate as errors • Camera Calibration: Intrinsic matrix assumes specific convention • Neural Networks: Misaligned features cause artifacts in upsampling
The "align_corners" Debate: PyTorch's grid_sample has an align_corners parameter that switches between these conventions. Getting this wrong causes subtle off-by-half-pixel errors in image generation models.
The choice between pixel-center and pixel-corner conventions introduces a half-pixel offset in all geometric operations. For sub-pixel interpolation, this means bilinear sampling at fetches different values in each convention. The error compounds in multi-scale pyramids and can cause visible misalignment in stitching.
In the 'pixel corners' convention, what sub-pixel coordinate represents the center of pixel (3, 5)?
Theory Exercise
Problem:
An image has dimensions 640×480 (width×height). A feature is detected at pixel location (400, 300) in image coordinates.
a) What is the location in centered coordinates (origin at image center)? b) If we flip the image horizontally (mirror), what are the new coordinates? c) If we rotate the image 90° clockwise, what are the new coordinates? (New dimensions: 480×640)
Hints:
- For centering, center is at (320, 240)
- For horizontal flip, only x changes
- For 90° clockwise rotation, the point moves: new_x = old_y, new_y = (old_width - 1) - old_x
Related Problems on PixelBank
Open a computer vision paper and the first real obstacle is rarely the idea; it is the line of symbols stating it. Why is one bold and another italic? What does the tilde in buy you, and why has a 2D point suddenly acquired a third number? Guessing costs you papers you could otherwise follow, and worse, it costs you bugs you cannot see. Chapter 0, Mathematical Foundations, already gave you the objects themselves: Vectors and Vector Operations covered what is and how norms and dot products behave, and Matrices and Transformations covered what does to it. This topic supplies the shared vocabulary for writing them down. We start with the bold-lowercase and bold-uppercase convention and the standard operators — transpose, inverse, determinant, trace, norm. Then image-specific notation: , per-channel symbols, and the derivatives , and in which every edge detector is written. Then homogeneous coordinates, the trick that turns translation into a matrix multiply. Finally the transformation matrices, convolution and morphology operators, and .
Definition
Computer vision uses a rich set of mathematical notations from linear algebra, calculus, and probability. Understanding these conventions is essential for reading papers, textbooks, and implementing algorithms. This section introduces the key notations you'll encounter throughout your study of computer vision.
In this topic
- 1Vectors and Matrices
- 2Image Notation
- 3Homogeneous Coordinates
- 4Transformations and Operators
Vectors and Matrices
means is an matrix of real numbers
Vectors are typically denoted with bold lowercase letters:
By convention, vectors are column vectors:
Matrices are denoted with bold uppercase letters:
Common Notation: • or — identity matrix (n×n) • — zero vector or matrix • — transpose (swap rows and columns) • — inverse matrix • or — determinant • — trace (sum of diagonal elements) • — norm (length) of vector
Vectors in represent both points and directions. The key distinction: points transform as (affected by translation) while directions transform as (translation-free). Confusing the two is a classic bug in 3D rendering and camera projection code.
If , find and .
Image Notation
Images are typically denoted as or :
• — intensity at pixel location • or — image at time (for video) • — red, green, blue channels • or — transformed or estimated image
For multi-channel images:
Derivative Notation: • — gradient (vector of partial derivatives) • — partial derivatives (also written ) • — second derivatives • — mixed partial derivative • — Laplacian (scalar) • — Hessian matrix of second derivatives
The function or equivalently unifies the continuous and discrete views. Differentiation gives edge detection (), integration gives area features (), and the notation lets us express any image operation as a mathematical operation — making proofs and analysis possible.
If pixel values are , estimate and at .
Homogeneous Coordinates
where denotes equality up to scale
Homogeneous coordinates add an extra dimension to represent points, enabling elegant handling of projective transformations.
A 2D point in homogeneous coordinates becomes:
To convert back: divide by the last coordinate:
Why use them?
- Translations become matrix multiplications
- Points at infinity can be represented ()
- Projective transformations are linear
- Camera projection is a simple matrix multiply
Transformation Hierarchy: • Euclidean (3 DOF): Rotation + translation — preserves distances • Similarity (4 DOF): + uniform scale — preserves angles • Affine (6 DOF): + shear, non-uniform scale — preserves parallel lines • Projective (8 DOF): Full 3×3 matrix — only preserves straight lines
Appending a 1 to get embeds into projective space . The payoff: translation, rotation, and scaling all become matrix multiplication. A full affine transform becomes the single matrix multiply , enabling clean composition via .
Convert homogeneous point to Cartesian coordinates.
Transformations and Operators
(Euclidean transformation)
(Projective/homography)
Common transformation matrices:
Rotation (2D by angle ):
Translation (using homogeneous coordinates):
Scaling:
Image Operations: • — Convolution: • — Element-wise (Hadamard) product • — Morphological dilation • — Morphological erosion
Optimization Notation: • — value of that minimizes • — minimum value of • — subject to (constraints)
CV operators form a hierarchy by the constraints on their matrices: for 2D images, rigid (rotation + translation, 3 DOF), similarity (+uniform scale, 4 DOF), affine (+shear and non-uniform scale, 6 DOF), projective (full 3×3 up to scale, 8 DOF). The same ladder in 3D has 6, 7, 12 and 15 DOF. Each level preserves less structure — rigid preserves distances, affine preserves parallelism, projective preserves only straight lines. Knowing which level you need determines the minimum number of point correspondences for estimation.
Write the translation matrix that moves points by .
Theory Exercise
Problem:
Given a 2D point :
a) Write this point in homogeneous coordinates b) Apply a rotation of 90° counterclockwise using the rotation matrix c) Apply a translation by using a homogeneous transformation matrix d) Combine rotation and translation into a single matrix and apply to the original point
Hints:
- For 90°, cos(90°)=0 and sin(90°)=1
- In homogeneous coords, multiply by translation matrix
- Combined: first rotate, then translate means T × R × p