Image Pyramids
An image pyramid stores an image at a sequence of resolutions, each level half the width and height of the one below. Drawn with the full image at the bottom and the smallest copy on top, the levels form a pyramid. Let be a normalized Gaussian low-pass filter, keep every other row and column, and upsample and interpolate to twice the height and width. The Gaussian pyramid of an image is
Each is a low-pass copy of . For a image, is and is .The Laplacian pyramid stores what each level adds to the next coarser one:
Each has the size of . It holds a band of frequencies about one octave wide, a factor of in frequency. So it is a band-pass image of detail at one scale. The top level is the coarse low-pass image. For the example with , the levels are , and .Collapsing the pyramid rebuilds the image, starting from the coarsest level:
The reconstruction is exact, , for any blur and any interpolation, as long as collapse uses the same as construction. The Gaussian pyramid alone loses detail, and the Laplacian levels store exactly the residuals that restore it. Discarding loses the lowest frequencies, including the mean brightness. A stack is the same construction without and . Every level keeps the full size, and the blur grows wider from level to level instead. Pyramids support coarse-to-fine search (Project 1 alignment), multiresolution blending (Burt and Adelson, 1983), scale-invariant feature detection, and texture synthesis.
Use the Same Twice
For exact reconstruction, the used in collapse must be identical to the one used to build , including its interpolation rule and its handling of odd sizes. Building with bilinear interpolation and collapsing with nearest-neighbor copies leaves an error at every level. The blur, by contrast, can be anything, since collapse never uses it.
Intuition
Image structure lives at many scales. The outline of a face spans hundreds of pixels, while skin pores span one or two. Many tasks need to treat each scale on its own, such as blending two photos or searching for an alignment. A pyramid gives each scale its own image, sized to its content. Coarse structure needs few pixels, so it gets a small image. Each level is made by blurring and then shrinking, which keeps the small images free of aliasing.
\usepackage{tikz}
\usepackage{amsmath}
\begin{document}
\definecolor{low}{HTML}{2F80ED}
\definecolor{band}{HTML}{D9483B}
\begin{tikzpicture}[>=latex,font=\small]
\filldraw[fill=low!20] (0.3,0) rectangle (2.7,2.4);
\filldraw[fill=low!20] (0.9,3.2) rectangle (2.1,4.4);
\filldraw[fill=low!20] (1.2,5.2) rectangle (1.8,5.8);
\node at (1.5,1.2) {$G_0$};
\node at (1.5,3.8) {$G_1$};
\node[left] at (1.15,5.5) {$G_2$};
\draw[->,thick] (1.5,2.45) -- (1.5,3.15) node[midway,left] {blur, $\operatorname{down}_2$};
\draw[->,thick] (1.5,4.45) -- (1.5,5.15) node[midway,left] {blur, $\operatorname{down}_2$};
\filldraw[fill=band!20] (6.3,0) rectangle (8.7,2.4);
\filldraw[fill=band!20] (6.9,3.2) rectangle (8.1,4.4);
\filldraw[fill=low!20] (7.2,5.2) rectangle (7.8,5.8);
\node at (7.5,1.2) {$L_0$};
\node at (7.5,3.8) {$L_1$};
\node[right] at (7.85,5.5) {$L_2 = G_2$};
\draw[->,thick] (2.75,1.2) -- (6.25,1.2) node[midway,above] {$G_0 - \operatorname{expand}_2(G_1)$};
\draw[->,thick] (2.15,3.8) -- (6.85,3.8) node[midway,above] {$G_1 - \operatorname{expand}_2(G_2)$};
\draw[->,thick] (1.85,5.5) -- (7.15,5.5) node[midway,above] {copy};
\node[right] at (8.75,1.2) {$256 \times 256$};
\node[right] at (8.15,3.8) {$128 \times 128$};
\node[right] at (7.85,5.05) {$64 \times 64$};
\node[low] at (1.5,-0.45) {Gaussian pyramid (low-pass)};
\node[band] at (7.5,-0.45) {Laplacian pyramid (band-pass)};
\end{tikzpicture}
\end{document}The Laplacian levels follow from a prediction view. The image is the best guess of that the coarser level can make. The difference is what that guess misses, namely the edges and texture at scale . Subtracting a blurred image from an image gives the “details” image of unsharp masking. The lecture notes that a unit impulse minus a Gaussian approximates the Laplacian of Gaussian, which gives the pyramid its name. The two pyramids trade off in opposite ways. Each Gaussian level repeats all the coarser content, while each Laplacian level holds only its own band.
Properties
(Signed Residuals) Laplacian levels contain negative values and average near zero.
A level is a difference of two images, so it is negative wherever the coarse prediction is too bright. Storing it in uint8 clips every negative value and destroys exact reconstruction. Keep the levels in floating point. For display, add or rescale each level, which is what the lecture’s “contrast enhanced to see detail” panels do. The top level is an ordinary image and stays positive.
(The Top Level Holds the Mean) Every detail level is blind to constant offsets.
The blur kernel sums to , and and keep a constant image constant. For a constant image every detail level is therefore exactly , and the whole image lives in . Adding a constant to any image changes only . The overall brightness and the broad color of a photo are stored in the small top level. This is why blending must blend the top level too, and why dropping it ruins reconstruction.
(Approximate Octaves) Each covers roughly the frequencies between the limits of and .
The image holds frequencies up to about the limit of its grid, and holds only the lower half of that range. Their difference is about one octave. The Gaussian is not an ideal cutoff, so neighboring bands overlap somewhat. The finest level reaches all the way up to cycle per pixel. The top level reaches all the way down to frequency .
(Overcomplete Storage) A Laplacian pyramid stores about as many numbers as the image.
Each level has a quarter of the pixels of the one below, so the total is at most times the image. This redundancy is the price of exact reconstruction with simple operations and direct access to each band. A stack with levels stores full-size images.
(Stacks) A stack skips and , so its blur must widen explicitly.
In a stack, is a blurred copy of at full size, , and . Collapse is the plain sum , which telescopes back to . In a pyramid, the same kernel at every level gives an effective blur that roughly doubles per level in original pixels. With at each level, the combined is about original pixels after to levels. Reapplying one fixed in a stack gives only , because Gaussian widths add in squares. To mimic a pyramid, double the total blur per level, for example by blurring the original with . Project 2 uses stacks, which keep every level aligned pixel for pixel with the image and the mask.
(Coarse-to-Fine Search) A pyramid turns a large search into a small search at the top plus small refinements.
Project 1 aligns color channels by trying every shift in a window and scoring each one. A shift of pixels at full size is a shift of pixels at level . The search starts at the coarsest level with a small window. At each finer level, the current estimate is doubled and refined within a window of or pixels. If the coarse estimate is within one coarse pixel of the truth, the doubled estimate is within two fine pixels, so suffices. Most of the cost comes from the finest level, where each score touches every pixel.
Derivation
We want to show that collapse returns exactly, whatever the blur and the interpolation. Collapse starts with , so the top level is exact. Suppose . The collapse step and the definition of give
The two terms are the same image, so they cancel. By induction from down to , every level is restored and . For the unrolled form is
a telescoping sum in which each supplies exactly the detail that could not predict. The argument never uses linearity or any property of the blur. Downsampling loses information inside the Gaussian pyramid. Each stores the lost detail at the resolution of , where it can still be represented.
Examples
(Easy) Sizes and Storage
A grayscale image is . We build Gaussian and Laplacian pyramids with , and also a Gaussian and Laplacian stack with three levels.
Give the size of every level. How many numbers does the Laplacian pyramid store, compared with the image and with the stack? at , at and at . Each matches , so the Laplacian levels have the same sizes, with .
The Gaussian levels are
The Laplacian pyramid stores numbers, which is times the pixels of . More levels push the ratio toward and never past it. The three-level stack stores numbers, three times the image.
(Medium) A Step Edge, Taken Apart and Rebuilt
One image row is , a dark region meeting a bright one. Build one level () with blur , copying the edge value outside the row. For , put old samples at even positions, average neighbors in between, and copy the last value.
Compute , and , and check the collapse. What remains if is discarded? What happens for a constant row? The blur gives , and keeping even positions gives . Expanding gives , so The detail level is zero in the flat regions and nonzero only around the edge, with both signs. Collapse adds back to and returns exactly.
Discarding leaves only , a small signed wiggle at the edge. The two brightness levels and are gone. A constant row, such as a gray card photographed at brightness , is worse. Its detail level is all zeros, so all of its content sits in . A second card at brightness has the same all-zero detail level. Without the top level, the two images cannot be told apart.
(Hard) Coarse-to-Fine Alignment Cost
Suppose a color channel in Project 1 is pixels, and the true shift between channels may be up to pixels in each direction. Scoring one candidate shift costs one operation per pixel of the current level.
Compare the cost of exhaustive search at full size with a five-level pyramid ( to ) that searches at each finer level. Exhaustive search tries shifts, each over pixels. That is about operations.
The coarsest level is pixels wide. A shift of pixels becomes coarse pixels, so a window of covers it. That costs operations. Each of the four finer levels tries shifts around the doubled estimate, costing
The total is about operations, roughly times fewer than exhaustive search. The finest level alone accounts for of them. The speedup works only if each coarse level is properly blurred before subsampling. An aliased coarse level can produce a wrong coarse shift, and the small refinement windows cannot correct it.
See Also
- 2.6. Multiresolution Blending, the main application of Laplacian pyramids in this course.
- 2.1.5. Template Matching, for the scores (SSD, NCC) used inside coarse-to-fine alignment.
- 4.1.2. Scale-Invariant Detection, which searches over scale with a related multiscale representation.
- 8.1. Parametric Texture Synthesis, which matches histograms of pyramid levels.