v9.1.1
Menu

Chapter 3: Image Processing

Week 3-4

Fundamental techniques for manipulating and enhancing digital images

Topics
6
Demos
2
Videos
4
Min read
39

Chapter Overview

Now that we understand how images are formed, it's time to manipulate them. Image processing provides the tools to enhance, filter, and transform images.

What is this chapter about? We cover the fundamental operations that transform pixel values—from simple brightness adjustments to sophisticated filtering using convolution. These are the building blocks used in every computer vision pipeline.

Why does this matter? Before any high-level analysis, images usually need preprocessing:

  • Noise reduction to clean up sensor artifacts
  • Contrast enhancement to make features more visible
  • Edge detection to find boundaries between regions
  • Frequency analysis to understand image structure at different scales

How the topics connect: We start with point operators that transform each pixel independently—simple but powerful. Then linear filtering introduces convolution, which considers neighborhoods of pixels. We explore the frequency domain where convolution becomes multiplication, enabling efficient processing. Finally, histogram analysis provides tools for contrast enhancement and image comparison.

Chapter Roadmap

Click any topic to jump in

Explainer videoInteractive demo
1
Point Operators

Per-pixel transforms, gamma correction, and histograms — operations that don't depend on neighbors.

Linear TransformGamma CorrectionHistogram
2
Color Transforms

RGB to grayscale, HSV conversion, and color matrices — changing color representations.

RGB to GrayscaleRGB to HSVColor Matrix
Neighborhood operations

Linear and non-linear approaches

3
Linear Filtering

Convolution, separable filters, and Gaussian blur — the workhorse of image processing.

Convolution OperationSeparable FiltersGaussian Filter
4
Non-linear Filtering

Median, bilateral, and morphological filters — edge-preserving operations that convolution can't do.

Median FilterBilateral FilterMorphological Operations
Theory and practice

Frequency analysis and spatial warping

5
Fourier Transforms

DFT and the convolution theorem — understanding images in the frequency domain.

Fourier TransformDiscrete Fourier Transform (DFT)Convolution Theorem
6
Geometric Transforms

Affine, bilinear interpolation, and homography — warping images to new coordinate systems.

Affine TransformationBilinear InterpolationHomography

Topics

6 topics in this chapter

The previous chapter explained how a scene becomes a grid of pixel values; this chapter begins the work of changing those values. The simplest way to change them is one pixel at a time, with an output that depends only on the single input pixel beneath it and nothing about its neighbors. That is a point operator, and despite its simplicity it covers a surprising amount of everyday image work: brightening an underexposed photo, stretching a washed-out one to full contrast, or bending midtones with a tone curve. Because each pixel is independent, these operations parallelize trivially across millions of pixels with no coordination. We build up three of them in order. First the linear transform, a gain-and-bias adjustment that scales contrast and shifts brightness. Then gamma correction, a nonlinear curve that matches the eye's response and undoes display encoding. Finally the histogram, which summarizes the whole distribution of intensities and sets up automatic contrast enhancement through equalization.

Definition

A point operator is an image transformation whose output at each pixel depends only on the input value at that same pixel, independent of every neighbor. Formally g(x,y)=T(f(x,y))g(x, y) = T(f(x, y)) for some function TT applied identically everywhere. Brightness, contrast, gamma, and tone curves are all point operators.

In this topic

  1. 1Linear Transform
  2. 2Gamma Correction
  3. 3Histogram
1 of 3
Linear Transform

g(x,y)=α⋅f(x,y)+βg(x,y) = \alpha \cdot f(x,y) + \beta

The linear transform is the most basic point operator, adjusting each pixel with a multiply and an add: g=αf+βg = \alpha f + \beta. The gain α\alpha controls contrast — values above 1 stretch the intensity range and spread pixels apart, values below 1 compress it. The bias β\beta is a brightness offset — positive shifts everything lighter, negative darker. Together they perform exposure correction and normalization. The operation is called linear because output is a straight-line function of input, so it cannot fix a nonlinear problem like a wrong gamma curve. Its most common use is contrast stretching: mapping an image's actual min and max onto the full 0 to 255 range.

Mathematical Intuition

The linear point operator g=αf+βg = \alpha f + \beta is a scalar affine map applied independently to each pixel. In vector terms, if the image is a vector f∈RHW\mathbf{f} \in \mathbb{R}^{HW}, then g=αf+β1\mathbf{g} = \alpha \mathbf{f} + \beta \mathbf{1} is an element-wise affine transform that shifts the mean by β\beta and scales the variance by α2\alpha^2. Contrast stretching is the special case that maps [fmin⁡,fmax⁡][f_{\min}, f_{\max}] onto [0,255][0, 255] via α=255/(fmax⁡−fmin⁡)\alpha = 255 / (f_{\max} - f_{\min}), which is the unique affine map satisfying the two boundary conditions.

Example:

An image has pixel values in range [40, 180]. Find α\alpha and β\beta to stretch this to [0, 255].

2 of 3
Gamma Correction

g(x,y)=255(f(x,y)255)γg(x,y) = 255 \left( \frac{f(x,y)}{255} \right)^\gamma

Gamma correction is a nonlinear point operator that raises the normalized pixel value to a power: g=255(f/255)γg = 255 (f/255)^\gamma. Unlike the linear transform it bends the tone curve rather than tilting it. With γ<1\gamma < 1 the curve lifts dark regions much more than bright ones, rescuing detail from underexposed shadows; with γ>1\gamma > 1 it pulls midtones down, taming overexposure. At γ=1\gamma = 1 nothing changes. The reason gamma matters is perceptual: human vision responds to light roughly logarithmically, so equal steps in encoded value look like equal steps in brightness only after a gamma curve. Standard sRGB bakes in γ≈2.2\gamma \approx 2.2, which is why raw linear light must be gamma-encoded before display and decoded before physically correct arithmetic.

Mathematical Intuition

Gamma correction applies the power-law nonlinearity g=255(f/255)γg = 255 (f/255)^\gamma, which is a monotonic concave function for γ<1\gamma < 1 and convex for γ>1\gamma > 1. The sRGB standard uses a piecewise function combining a linear segment near zero with a γ≈2.2\gamma \approx 2.2 power law. In information-theoretic terms, gamma encoding allocates more code values to dark tones where human contrast sensitivity dL/dIdL/dI is highest, effectively performing a form of perceptual quantization that minimizes visible banding for a fixed bit depth.

Example:

A pixel has intensity 100. What is its value after gamma correction with γ=0.5\gamma = 0.5 (brightening)?

3 of 3
Histogram

H(i)=∑x,yδ(f(x,y)−i)H(i) = \sum_{x,y} \delta(f(x,y) - i)

A histogram is not a transform but a summary: it counts how many pixels hold each intensity value, turning the image into a distribution. Its shape diagnoses the image at a glance. A narrow spike means low contrast, values crowded into a small band; a wide spread means the full tonal range is in use. A mass piled at the left signals a dark, underexposed frame, piled at the right an overexposed one. The histogram also drives automatic enhancement: histogram equalization computes the cumulative distribution and remaps intensities so the output histogram is as flat as possible, expanding contrast without any manual gain or bias tuning.

Mathematical Intuition

The histogram H(i)H(i) estimates the probability mass function p(i)=H(i)/Np(i) = H(i)/N of pixel intensities. Histogram equalization seeks a monotonic mapping TT such that the output CDF is approximately uniform: T(i)=⌊(L−1)⋅CDF(i)⌋T(i) = \lfloor (L-1) \cdot \text{CDF}(i) \rfloor where CDF(i)=∑j=0ip(j)\text{CDF}(i) = \sum_{j=0}^{i} p(j). This is an application of the probability integral transform — for continuous random variables, if X∼FX \sim F, then F(X)∼Uniform(0,1)F(X) \sim \text{Uniform}(0,1). The discrete version only approximates uniformity because the CDF is a step function.

Example:

A 4×4 grayscale image has values: [0,0,1,1, 0,1,2,2, 1,2,2,3, 2,3,3,3]. Compute its histogram for range [0,3].

Theory Exercise

Problem:

An 8-bit grayscale image has pixel values ranging from 50 to 150. You want to stretch this to use the full range [0, 255]. What linear transformation parameters (α, β) should you use?

Hints:
  • Find the current range: max - min
  • Target range is 255 - 0 = 255
  • α (gain) = target_range / current_range
  • β (bias) must map the minimum value to 0