Sampling Resampling Warping Morphing
- Dr. Shai Avidan
Sampling Resampling Warping Morphing Dr. Shai Avidan Faculty of - - PowerPoint PPT Presentation
Sampling Resampling Warping Morphing Dr. Shai Avidan Faculty of Engineering Tel-Aviv University Slide Credits (Partial List) Alyosha Efros Steve Seitz Rick Szeliski Bill Freeman Fredo Durand
Sampling/Resampling/Warping/Morphing/Retargeting
– Given a continuous signal g(x) and its sampled counterpart g_s(x), are the samples of g_s(x) sufficient to exactly describe g(x)? – If so, how can g(x) be reconstructed from g_s(x)?
– Image resampling is the process of transforming a sampled image from one coordinate system to another
– Is a geometric transformation that redefines the spatial relationship between points in the image
– Is the process of blending two images
– Is a content-aware resizing operation
– write down the function’s values at many points
[FvDFH fig.14.14b / Wolberg]
– for output (need realizable method) – for analysis or processing (need mathematical method) – amounts to “guessing” what the function did in between
[FvDFH fig.14.14b / Wolberg]
low high frequencies
– how can we be sure we are filling in the gaps correctly?
– unsurprising result: information is lost
– unsurprising result: information is lost – surprising result: indistinguishable from lower frequency
– unsurprising result: information is lost – surprising result: indistinguishable from lower frequency – also was always indistinguishable from higher frequencies – aliasing: signals “traveling in disguise” as other frequencies
Slide by Steve Seitz
Input signal:
x = 0:.05:5; imagesc(sin((2.^x).*x))
Plot as image:
Alias! Not enough samples
– Join the Mega-Pixel craze of the photo industry – But this can’t go on forever
– Get rid of some high frequencies – Will loose information – But it’s better than aliasing
– remove high frequencies leaving only safe, low frequencies – choose lowest frequency in reconstruction (disambiguate)
Imaging subsystem *h(x,y) Sampling Subsytem *s(x,y) Quantizer
f(x,y) g(x,y) gs(x,y) gd(x,y)
Digitized Image Scene Image Sampled Image
g(x,y)=f(x,y)*h(x,y) The scene is mapped to the image via the point spread function of the camera h(x,y) gs(x,y)=g(x,y)s(x,y) The continuous image g(x,y) then enters A sampling subsystem 2D comb function s(x,y) given by:
n
n y m x y x s , ,
image with intensity values defined only over integral indices of x and y After sampling, the quantizer takes the continuous Intensity values and quantizes them (either uniform or non-uniform)
We start with continuous signal f(x). Due to the psf We obtain a degraded, band-limited output g(x). The frequency content of g(x) is given by its spectrum, G(f), as determined by the Fourier transform:
ic fx e dx e x g f G
fx i fx i
sin 2 cos
2 2
Spatial frequency. Since g(x) does not have any frequencies beyond fmax, we say that it is band-limited. |G(f)|
fmax
The continuous output g(x) is then digitized by an ideal Impulse sampler, the comb function, to get the sampled signal gs(x). The ideal 1-D sampler is given by:
s
nT x x s
impulse train of the comb function. We now have:
x s x g x gs
Taking the Fourier transform of gs(x) yields
s s n s s s
nf f G f nf f f f G f S f G f G * *
We make use of the following properties of the Fourier Transform 1. Multiplication in the spatial domain corresponds to convolution in the frequency domain. 2. The Fourier transform on an impulse train is itself an impulse train. 3. The spectrum of a signal sampled with frequency fs (Ts=1/fs) yields the
|Gs(f)|
fmax
fs
The above result reveals that the sampling operation has left the
the frequency domain with a spacing of f_s. This allows us to rewrite G_s(f) as a sum of two terms, the low frequency (baseband) and high frequency components. The baseband specturm is exactly G(f), and the high frequency components, G_high(f), consist of the remaining replicated versions of G(f). G_s(f) = G(f) + G_high(f) Exact signal reconstruction from sampled data requires us to discard the replicated spectra G_high(f), leaving only G(f), the spectrum of the signal we seek to recover.
The only provision for exact reconstruction is that G(f) be undistorted due to overlap with G_high(f). Two conditions must hold for this to be true: 1. The signal must be bandlimited. This avoids spectra with infinite extent that are impossible to replicate without
condition is satisfied in practice). 2. The sampling frequency f_s must be greater than twice the maximum frequency f_max, present in the signal. This minimum sampling frequency, known as the Nyquist rate, is the minimum distance between spectra copies, each with bandwidth f_max. f_s>f_nyquist=2*f_max
Given that it is theoretically possible to perform reconstruction, how may it be done? The act of reconstruction requires us to completely suppress G_high(f). This is done by multiplying G_s(g) with H(f) given as:
max
1 f f f f f H
|Gs(f)|
fmax
fs
H(f)
In the spatial domain, the ideal low-pass filter is derived by computing the inverse Fourier transform of H(f). This yields the sinc function defined as: Since multiplication in the frequency domain is identical to convolution in the spatial domain, then we can convolve the sample signal g_s(x) with sinc(x) to obtain the continuous g(x). The problem is that sinc(x) requires infinite support which is impossible in practice.
x x
sinc
x g x g x x g
s s
* sinc
When using a truncated sinc function for reconstruction we get
the overshoots and undershoots caused by reconstructing a signal with truncated frequency terms. Approximations to the ideal low pass filter balance between tampering frequencies below f_max and not suppressing fully frequencies above it.
Since H(f), the ideal filter cannot be computed in practice, we resort to nonideal filters.This bring up the problem of how to assess the quality of a filter
|G(f)|
fmax
fs
Hr(f)
H_r(f) attenuate some frequencies that should remain intact and pass and pass some of the high frquency that should be suppressed. This leads to the problem of aliasing: aliasing: signals “traveling in disguise” as other frequencies high frequencies disguised as low frequencies
aliasing: signals “traveling in disguise” as other frequencies It can be solved in one of two ways: 1. Increasing sampling rate (to reach Nyquist rate) 2. Applying low pass filter (to bandlimit the signal)
Slide by Steve Seitz
So, we have a discrete image and we want to warp it to another discrete
straightforward procedure. First, the inverse mapping function is applied to the output sampling grid, projecting it onto the input. The result is a resampling grid, specifying the locations at which the input is to be
values are assigned to their respective output pixels. The problem is that resampling grid does not coincide with the input sampling grid. The solution is to reconstruct the input image to a continuous image and then do the sampling.
There are four basic elements to ideal image resampling: reconstruction, warping, prefiltering and sampling.
2D texture space 2D screen space warp due to perspective
f(u) g(x) m
f(u) g(x) m
1. Reconstruct the continuous signal from the discrete input signal 2. Warp the domain of the continuous signal 3. Prefilter the warped continuous signal 4. Sample this signal
f(u) g(x) m
fc(u) = f(u) * r(u) = _{k \in Z} f(k) r(u-k)
f(u) g(x) m
discrete input warp warped input reconstructed input reconstruct continuous output prefilter source space resampling with prefiltering [Heckbert 89] discrete output sample destination space
= s gc(t) h(x-t) dt = s fc(m-1(t)) h(x-t) dt = s h(x-t) å f(k) r(m-1(t)-k) dt = _k f(k) (x, k)
h(x – t) r (m-1(t) –k) dt
filter and a low-pass filter
m^{-1}. Since it falls on non-integer pixel value we use the reconstruction filter r to interpolate the discrete input signal f, and to make sure the result conforms to the Nyquist rate we bandlimit it with the function h
i i
1
resampling filter
reconstruction kernels reconstructed input position color irregular spacing
Source Space
Destination Space
Destination Space
Destination Space
low-pass filter convolution resampling filters sum of resampling filters warped reconstruction kernel
Source Space
Destination Space
Destination Space
Destination Space
reconstruction filter and a low-pass filter
i i
1
resampling filter
– Closed under affine mappings and convolution
i i i
1
i i
Gaussian resampling kernel (EWA resampling kernel)
approximated by local affine at center of kernel
because filter small at periphery
warped recon- struction kernel low-pass filter resampling filter
minification magnification
EWA trilinear mipmapping
In the special case of magnification, we may ignore the prefilter altogether, treating it instead as an impulse function. This is due to the fact that no high frequencies are introduced into the output upon magnification. So we only have to do reconstruction (i.e., interpolation). Conversely, minifcation introduces high frequencies and does not require any reconstruction (i.e., interpolation) filter and treat it simply as an impulse function. Therefore, 1) For magnification we only need to interpolate 2) For minification we need to low-pass filter and then sub-sample.
For magnification, the shape of the reconstruction filter does not change in response to the mapping function. In minifcation the reconstruction filter is replaced by a prefilter. Unlike reconstruction filters, though, the actual shape must be scaled by an amount linearly related to the minifcation
broader and shorter. It becomes broader in order to average more neighboring pixel together, thereby further bandlimiting the input. Since larger neighborhood are used to compute each output pixel, the normalized weights applied to the input decrease to reflect the diminishing impact of each input sample. As a result, the prefilter grows shorter.
Interpolation is the process of determining the values of a function at positions lying between its samples. I achieves this process by fitting a continuous function through the discrete input samples. For equally spaced data, interpolation can be expressed as: Where h is the interpolation kernel weighted by coefficients c_k and applied to K data sample x_k
K k k k
x x h c x f
Nearest neighbor method is given by the following interpolating polynomial: It can be achieved by convolving the image with a one-pixel width rectangle in the spatial domain. The interpolation kernel for the nearest neighbor algorithm is defined as Due to the prominent side lobes and infinite extent, a sinc function makes a poor low-pass filter.
2
1 1
k k k k
x x x x x x f x f
x x h 5 . 5 . 1
Linear interpolation method is given by the following interpolating polynomial: In the spatial domain, linear interpolation is equivalent to convolving the sampled input with the following interpolation kernel (tent filter)
1 1 1 1 1 1
polynomial ing interpolat following the gives This 1 1 : solving by determined are , where , f f x x x x f x f x x a a f f a a a x a x f
! " #
x x x h 1 1 1
Michael Jackson’s “Black or White” Cross-fading