Multiresolution Blending
Blending joins two aligned images and so that one shows on each side of a seam and the seam is invisible. Alpha blending, also called feathering, mixes the two images with a weight that ramps across a transition window of width :
The weight falls from to across the window. A window that is too narrow leaves a visible seam. A window that is too wide causes ghosting, where both images show through like a double exposure. To avoid seams, should be about the size of the largest prominent feature. To avoid ghosting, should be at most twice the size of the smallest prominent feature. Both rules can hold only when the image’s frequency content spans at most one octave, meaning its largest frequency is at most twice its smallest.Multiresolution blending (Burt and Adelson, 1983, “A Multiresolution Spline With Application to Image Mosaics”) handles images with a wider frequency spread. It splits each image into a Laplacian pyramid with one octave per level, blends each level separately, and collapses the result. Let the mask equal where should appear and where should appear. The single-scale mask blend and the per-level blend are
with every product and sum taken pixel by pixel. Here and are level of the two Laplacian pyramids, whose top level is the Gaussian level . The weight is level of the Gaussian pyramid of the mask, with and . Collapsing the blended levels gives the result. Coarse levels get wide transitions and fine levels get narrow ones, so every band meets the window rules. The mask can have any shape, such as an ellipse that places an eye in a palm.Two-band blending (Brown and Lowe, 2003) simplifies the method for stitched panoramas. It uses only two bands and no downsampling. The low band, with features larger than about pixels, is blended smoothly. The high band, with features smaller than pixels, is blended with a binary .
Three Ways to Write the Mask
The lecture’s feathering slide weights the left image by . Its mask slides weight by , so selects . On those slides is pixel-wise multiplication, and it does not denote convolution. Discussion 4 uses a mask that is on the left half and selects . It writes feathering with a smoothed mask as , where is pixel-wise multiplication. Per level it writes . All three describe the same algorithm. Setting converts between the mask forms, and when is the left image.
Intuition
Consider the lecture’s apple and orange, cut down the middle. A hard cut leaves a seam, because the red and orange colors jump from one pixel to the next. A soft cross-fade over a wide window hides the color jump. It also averages the apple’s skin with the orange’s peel over that whole width, so both textures show at once. The conflict is about window width. Broad color changes need a wide window, and fine textures need a narrow one. When one image holds both, no single window serves.
\usepackage{tikz}
\usepackage{amsmath}
\begin{document}
\definecolor{wa}{HTML}{2F80ED}
\definecolor{wb}{HTML}{D9483B}
\begin{tikzpicture}[x=1.2cm,y=2.4cm,>=latex,font=\small]
\draw[->] (-3.2,0) -- (3.5,0) node[right] {$x$};
\draw[->] (-3.2,0) -- (-3.2,1.3);
\node[left] at (-3.2,1) {$1$};
\node[left] at (-3.2,0) {$0$};
\draw[very thick,wa] (-3.2,1) -- (-1,1) -- (1,0) -- (3.2,0);
\draw[very thick,wb,dashed] (-3.2,0) -- (-1,0) -- (1,1) -- (3.2,1);
\draw[dotted] (0,0) -- (0,1.05);
\node[below] at (0,0) {seam};
\draw[<->] (-1,-0.32) -- (1,-0.32) node[midway,below] {window $w$};
\node[wa,anchor=south west] at (-3.1,1.02) {$\alpha(x)$: weight of $I_{\text{left}}$};
\node[wb,anchor=south east] at (3.3,1.02) {$1 - \alpha(x)$: weight of $I_{\text{right}}$};
\end{tikzpicture}
\end{document}The fix is to separate the scales first. A Laplacian pyramid puts each octave of detail in its own image, so each band can get its own window. Blurring the mask once per level makes the windows wider at coarser levels, so the window grows with the feature size. Burt and Adelson called the result a multiresolution spline, where a spline means a smooth join between two pieces. The method blends at many resolutions at once.
Properties
(Window Grows With Level) A transition a few pixels wide at level is times wider in original pixels.
Each pixel of level covers original pixels. The mask level has been blurred times, and its transition spans a few level- pixels. After collapse, that transition is spread over a few times original pixels. Fine levels such as and meet across a pixel or two, so fine textures never overlap. Coarse levels meet across tens of pixels, so broad colors change gradually. Each band sits in one octave, so each band meets both window rules.
\usepackage{tikz}
\begin{document}
\definecolor{wb}{HTML}{D9483B}
\begin{tikzpicture}[x=1cm,y=0.7cm,>=latex,font=\small]
\foreach \y/\h/\l/\wl in {0/0.3/m_0/w, -1.6/0.6/m_1/2w, -3.2/1.2/m_2/4w} {
\draw[->] (-3,\y) -- (3.3,\y) node[right] {$x$};
\draw[very thick,wb] (-3,\y) -- ({-\h},\y) -- (\h,{\y+1}) -- (3,{\y+1});
\node[left] at (-3.1,{\y+0.5}) {$\l$};
\draw[<->] ({-\h},{\y-0.3}) -- (\h,{\y-0.3}) node[midway,below] {$\wl$};
}
\node[anchor=west] at (-3,1.6) {mask level, shown at full size ($1$ selects $I^B$)};
\end{tikzpicture}
\end{document}(Gaussian Mask, Not Laplacian) The per-level weights must stay between and and still say which image to use.
A blur with a nonnegative kernel that sums to keeps every value of in . Each blended pixel is then a weighted average of the two images’ pixels at that level. Far from the seam, is still on one side and on the other. Laplacian levels of the mask fail both tests. They describe changes between scales, and they can be negative. They are also near away from the seam, so they no longer encode ” on one side, on the other”. Discussion 4 makes this point.
(Blend the Top Level Too) The top level carries the mean colors, so it needs the widest transition.
The top level holds the low-pass content of each image, including its average brightness and broad color. Blending it with , the blurriest mask level, spreads the red-to-orange change over a wide region. If the top level is copied from one image, that image’s colors show through across the whole result. Discussion 4 says to blend the coarsest level as well and then collapse.
(Stacks Need a Blurred Mask) With Laplacian stacks, a binary mask at every level leaves a hard seam.
In a pyramid, collapse expands every coarse level. Expanding a level with a hard seam turns that seam into a ramp original pixels wide. That smoothing is why the simpler algorithm in Burt and Adelson’s paper, which joins each level at a hard seam, still works with pyramids. A stack never expands anything. A hard seam at every level, including the low-frequency one, stays hard after the levels are summed. Project 2 therefore requires a Gaussian stack of the mask, blurred with the same growing as the image stacks.
(Two Bands for Panoramas) Panorama images are already aligned, so two bands without downsampling are enough.
Neighboring panorama photos are warped into a common frame, for example with homographies. They differ mainly in exposure, and their fine detail is often slightly misaligned. A binary on the high band keeps each pixel’s fine detail from one photo only, which prevents doubled edges. A smooth on the low band hides the exposure difference. Two full-size bands are cheaper than a full pyramid, and they avoid resampling the images again.
Examples
(Easy) A Brick Facade
Two photos of a brick facade are aligned and joined along a vertical seam. The bricks are about pixels tall. The shading across the wall changes over about pixels.
Can a single feathering window avoid both a seam and ghosting? If not, about how many octaves must a pyramid separate? pixels. To avoid ghosted bricks, the window must be at most twice the smallest feature, pixels. No satisfies both. The feature sizes span a factor of , which is octaves. A pyramid with about levels splits the image so that each level holds roughly one octave, and each level gets its own window.
To avoid a seam in the shading, the window must be about the largest feature,
(Medium) Where the Apple Meets the Orange
The apple and orange images are , blended with Laplacian pyramids with (six levels, ) and a vertical step mask. Assume each mask level changes from to over about pixels of level .
Give the size of every level and the width of each transition in original pixels. At which level do the red and orange colors meet, and over what width? , , , , and pixels wide for . A level- pixel spans original pixels, so level- pixels span original pixels. The transitions are about and original pixels wide.
The levels are
The average colors live in the top level, where each pixel covers a patch of the original. Red and orange therefore blend across about pixels, a quarter of the image width. The skin and peel textures in meet across about pixels, so they never overlap.
(Hard) The Seam That Would Not Go Away
A student blends two flat sky patches, and everywhere, each pixels wide, with a step mask at the center. The student uses Laplacian stacks with , where is the image blurred with for . The binary mask is used unchanged at every level.
What do the Laplacian levels look like? What does the student's blend produce, and what changes with a Gaussian stack of the mask? equals the constant. Every detail level is , and the whole image sits in the top level . The blended result therefore equals the blended top level.
Blurring a constant image leaves it unchanged, so every
With the binary mask at every level, the blended top level is on the left and on the right. It jumps between two adjacent pixels, which is a hard seam.
With a Gaussian stack of the mask, the top weight is the step blurred with . The result rises smoothly from to . For a blurred step, the rise from to of the way takes about , so here it takes about pixels. The brightness difference between the skies fades across the center with no visible seam.
See Also
- 2.5. Image Pyramids, for building and collapsing the Gaussian and Laplacian levels.
- 2.7. Hybrid Images, another method that combines the low and high frequencies of two images.
- 3.5. Image Morphing, whose cross-dissolve is alpha blending applied over time.
- 3.4. Homographies, which align the images that panorama blending joins.