4.0 BASIC IMAGE PROCESSING AND ISP⧉
This part focuses on the surprisingly serious number of steps and methods needed to go from a sensor reading to an image file stored on disk, and on the methods in use today on a typical camera, phone, or photo editor such as Adobe Lightroom. It also introduces the critical signal- and image-processing tools needed to understand them, in particular Fourier analysis. And it illustrates the range of computational photography, from objective photometric criteria to subjective beautification curves and color grading. By the end of this part you should be able to build the core of a small photo editor, a mini Lightroom with exposure, contrast, color, sharpening — or the camera-side version of the same machinery, the image signal processor that turns raw sensor data into a finished JPEG.
This part covers a lot of material. Almost every operation you associate with a photo app or a camera is in this part: making a picture brighter or punchier, fixing its color, sharpening it, blurring it, scaling it up or down, cleaning up noise, saving it small enough to send. Underneath that variety sit a handful of ideas that recur the whole way through, and we will meet them in an order designed so each one earns the next. We start with the representation itself: what the array is, what its numbers mean, and the small conventions (coordinates, channels, edges) that quietly cause most beginner bugs (this chapter). Because image code is famously easy to get subtly wrong, we then spend a short chapter on how to develop, test, and debug it, the habits that save you later. With that in hand we look at point operations (a curve applied to every pixel: exposure, contrast, tone, histograms), then tone mapping for scenes whose range outruns the display, then neighborhood operations and convolution (a pixel computed from its neighbors: blur, sharpen, gradients). Convolution opens the door to Fourier, which gives us the language for sampling, aliasing, and resampling, and the pyramids that represent an image at many scales at once. We close with the pieces a real camera bolts together: file formats and compression (how a JPEG actually works), the metrics by which images are compared, denoising and demosaicking, and finally the image signal processor, the fixed pipeline from raw sensor data to a finished JPEG that ties every chapter of this part into one block diagram.
One thread runs through all of it, and it is worth stating up front because it will save you grief: the same array of numbers can mean different things, depending on how it is encoded. Do the physics, combining exposures, white balance, and blurring, on linear values that are proportional to light; do the display and the compression on gamma-encoded values tuned to perception; and reach for log when the range is enormous. Knowing which of these a given operation wants is half of getting image processing right.
Contents of this part
- 4.1 Image representation
- 4.1.1 An image is an array
- 4.1.2 Float vs 8-bit vs more bits
- 4.1.3 Stochastic Quantization and Dithering
- 4.1.4 How the array sits in memory
- 4.1.5 Pixel coordinate conventions
- 4.1.6 Alpha and extra channels
- 4.1.7 Video and more dimensions
- 4.1.8 Pixel lookups and boundaries
- 4.1.9 Beyond the pixels: basic metadata and EXIF
- 4.1.10 Three kinds of operation
- 4.2 What the numbers mean
- 4.3 Developing, Testing and Debugging
- 4.4 Point operations
- 4.4.1 Three kinds of operation
- 4.4.2 The point-operation curve
- 4.4.3 Exposure: a multiply in linear light
- 4.4.4 Brightness vs. exposure
- 4.4.5 Contrast: steepen about a pivot
- 4.4.6 Black point, white point, and levels
- 4.4.7 The general tone curve
- 4.4.8 Basic color enhancement: saturation and vibrance
- 4.4.9 Converting to black and white
- 4.4.10 Lookup tables
- 4.4.11 Video color grading
- 4.4.12 Local point operations
- 4.5 Histograms
- 4.6 Global tone mapping
- 4.6.1 The dynamic-range problem
- 4.6.2 Two families: global and local
- 4.6.3 Global tone mapping: one curve for everything
- 4.6.4 Histogram equalization and Ward's bound
- 4.6.5 Local tone mapping and the halo problem: why naive local fails
- 4.6.6 Why log space pays off
- 4.6.7 The analog ancestor: the Zone System
- 4.6.8 HDR on every screen: the gain map
- 4.6.9 Where this is going
- 4.7 Beauty curves: the camera "look"
- 4.8 Neighborhood operations and convolution
- 4.8.1 Motivation: blur and sharpen
- 4.8.2 Convolution 101
- 4.8.3 The flip: where-from vs. where-to
- 4.8.4 Properties: the impulse, normalization, symmetry, commutativity
- 4.8.5 Nitty-gritty: finite images
- 4.8.6 A blur zoo
- 4.8.7 Separability
- 4.8.8 Gradient and oriented filters
- 4.8.9 Is imaging blur usually a shift-invariant convolution?
- 4.8.10 Where this goes next
- 4.9 Sharpening
- 4.10 Fourier
- 4.10.1 Images as vectors in a high-dimensional space
- 4.10.2 why Fourier
- 4.10.3 Definition: one coefficient per wave
- 4.10.4 Sines are the eigenvectors of convolution
- 4.10.5 The 2-pixel example
- 4.10.6 Reading an image's Fourier transform
- 4.10.7 A small bestiary of transforms
- 4.10.8 The fine print: two limitations of Fourier
- 4.10.9 Windowing: the price of measuring a real spectrum
- 4.10.10 Application preview: can we deblur, given the blur?
- 4.11 Sampling, downsampling, and aliasing
- 4.11.1 Aliasing: a high frequency in disguise
- 4.11.2 Nyquist and the sampling theorem
- 4.11.3 In two dimensions, aliasing has a direction
- 4.11.4 Sampling in the frequency domain: spectral replicas
- 4.11.5 Seeing it: sampling and pre-filtering, hands on
- 4.11.6 The ideal reconstruction filter: sinc, and why it is unreachable
- 4.12 Resampling and upsampling
- 4.12.1 Domain operations: moving pixels around
- 4.12.2 Start with scaling up
- 4.12.3 The naive idea, and why it leaves gaps
- 4.12.4 Loop over the output, use the inverse transform
- 4.12.5 Nearest neighbor
- 4.12.6 Linear interpolation, in 1-D first
- 4.12.7 Bilinear, in 2-D
- 4.12.8 The convolution perspective
- 4.12.9 Better kernels: bicubic and Lanczos
- 4.12.10 Upsampling vs. downsampling: scale the kernel
- 4.12.11 Prefiltering when the transform isn't a clean scale
- 4.12.12 Beyond Nyquist-limited reconstruction
- 4.12.13 Where this goes next
- 4.13 Pyramids and wavelets
- 4.13.1 Halfway between space and frequency
- 4.13.2 The idea: process an image at many resolutions
- 4.13.3 The Gaussian pyramid
- 4.13.4 The Laplacian pyramid
- 4.13.5 Reconstruction: an exact encoder and decoder
- 4.13.6 Each level is a frequency band
- 4.13.7 What the bands look like on a real image
- 4.13.8 Candid limitations
- 4.13.9 Cousins: wavelets and steerable pyramids
- 4.13.10 Pyramid blending
- 4.13.11 Other applications
- 4.13.12 Multiresolution as a recurring theme
- 4.14 Image metrics
- 4.14.1 Full-reference vs. no-reference
- 4.14.2 why not just L2?
- 4.14.3 PSNR
- 4.14.4 SSIM
- 4.14.5 VDP and HDR-VDP
- 4.14.6 learned metrics
- 4.14.7 The right metric depends on the task
- 4.15 Denoising basics
- 4.15.1 what is noise?
- 4.15.2 denoising by averaging multiple shots
- 4.15.3 denoising from a single image
- 4.15.4 Spatial averaging and its limits
- 4.15.5 The bilateral filter: averaging by affinity
- 4.15.6 Denoising in the pyramid: coring
- 4.15.7 Denoise color more than brightness
- 4.15.8 noise estimation
- 4.15.9 The limits of denoising
- 4.16 Demosaicking
- 4.16.1 Reminder: the Bayer mosaic
- 4.16.2 The task: full RGB at every pixel
- 4.16.3 The naive approach: interpolate each channel on its own
- 4.16.4 Why naive interpolation zippers: averaging across an edge
- 4.16.5 Doing better: edge-directed interpolation
- 4.16.6 The harder half: red and blue, and color fringing
- 4.16.7 Green-based demosaicking: interpolate the color difference
- 4.16.8 Classic (non-learning) demosaicking: the general strategy
- 4.16.9 Related: the optical anti-aliasing filter
- 4.16.10 Quad-Bayer sensors: remosaic before demosaicking
- 4.16.11 Fuji X-Trans: a larger, irregular CFA
- 4.16.12 Beyond hand-tuned: joint denoising and learned demosaicking
- 4.16.13 Cross-reference: other ways to sense color
- 4.16.14 Where this sits in the pipeline
- 4.17 Auto-exposure and auto white balance
- 4.18 File formats and compression
- 4.19 Recap ISP, non-destructive editing: