Program
This is the recursion that constructs an image's laplacian and gaussian pyramids...
next gaussian = blur gaussian
next laplacian = original - next gaussian
--------------------------------------------------
With this representation, the k-th level of the gaussian pyramid contains all the lower frequencies below the cutoff (i.e. later on the pyramid), while the k-th level of the laplacian pyramid contains all the higher frequencies above the cutoff (i.e. sooner on the pyramid). Thus, to create my hybrid images (i.e. to merge two pyramids), you just add two levels.
Hybrid Images
CatDog
gray
color
params
| |
pyramid levels computed | 10 |
cutoff level for first image | 6 |
cutoff level for second image | 7 |
sigma (gaussian filter) | 3 |
width (gaussian filter) | 18 |
Einstein on top of Marilyn
params
pyramid levels computed | 16 |
cutoff level for first image | 11 |
cutoff level for second image | 12 |
sigma (gaussian filter) | 0.75 |
width (gaussian filter) | 5 |
Furry Derek
furry
really furry
params
| |
pyramid levels computed | 4 |
cutoff level for first image | 1 |
cutoff level for second image | 2 |
sigma (gaussian filter) | 3 |
width (gaussian filter) | 18 |
Original (Spec-respecting) Algorithm
Laplacian and Gaussian Pyramids
CatDog
"ART"
Design
Laplacian Pyramid Representation
- i = original image
- GaussianPyramid k = gaussian^k i
- LaplacianPyramid k = i - gaussian^k i
The k-th level of the laplacian pyramid contains all higher-frequencies. This translates to the sum of all lower-levels in the suggested representation).
This is nice in a few ways:
- 1. mirrors the gaussian pyramid (in fact, is its complement)
- 2. merging two images' pyramids is simply adding two levels.
(Of course, for efficiency, the implementation avoids recomputation of gaussian^k by caching it in the pyramid).
No Subsampling
While slower, I found that not subsampling is a lot better. It makes preserving color trivial (comment out a line of code); and it avoids recomputing (in particular, rescaling) the gaussian filter; and, most importantly, it produced better images for me (as you can see). Fewer variables are easier to optimize.
<DeepThoughts> So, my image 'pyramid' is actually an image 'prism'. </DeepThoughts>
Color
I decided to preserve color in the low-passed image. <DeepThoughts> I'm not sure, but I think that a low-passed image with color looks better (i.e. more natural) than a high-passed image with color because color is itself a low-frequency phenomnenon. In other words, hue is often uniform. Upto an object, that is. </DeepThoughts> My actual reason, however, is purely empirical. That is, I tried all 4 permutations of color versus grayscale crossed with first image versus second image.
Parameters
- let N = number of levels to compute
- let C1,C2 = cutoff frequencies (i.e. which levels to keep)
- let sigma = variance of gaussian filter
Hand-tuning. Lots of hand-tuning. I played around directly with all of them, but with N and C1 the most. C2 is a function of C1. Computing the next level of a gaussian pyramid is simply squaring a gaussian; and squaring a gaussian is simply changing its sigma. Thus, the 'significant statistics' of my hybrid image algorithm are the images, N, and C1.