19. Temporal filters
19.1 Introduction
Although adding time might seem like a trivial extension from 2D signals to 3D signals, and in many aspects it is, there are some properties of how the world behaves that make sequences different from arbitrary 3D signals. In 2D images, most objects are bounded, occupying compact and well-defined image regions. However, in sequences, objects do not appear and disappear instantaneously unless they get occluded behind other objects or enter or exit the scene through doors or the image boundaries. So, the behavior of objects across time is very different than their behavior across space . In time, objects move and deform, defining continuous trajectories that have no beginning and never end.
19.2 Modeling sequences
Sequences will be represented as functions , where are the spatial coordinates and is time. As before, when processing sequences, we will work with the discretized version that we will represent as , where are the pixel indices and is the frame number. Discrete sequences will be bounded in space and time, and can be stored as arrays of size .
Figure 19.1: Fig (a) 8 Frames from a sequence with people walking. The frames are shown at regular time intervals. The full sequence had 90 frames (corresponding to 3 seconds of video). b) Space-time array, of size . c) Section for , d) Section for . Static objects appear as straight lines.
Figure 19.1 illustrates this with one sequence shown in Figure 19.1 (a). This sequence has 90 frames and shows people on the street walking parallel to the camera plane and at different distances from the camera. Figure 19.1 (b) shows the space-time array . When we look at a picture, we are looking at a 2D section, =constant, of this cube. But it is interesting to look at sections along other orientations. Figure 19.1 (c) and Figure 19.1 (d) show sections for =constant and =constant, respectively. Although they are also 2D images, their structure looks very different from the images we are used to seeing. Figure 19.1 (c) shows a horizontal section that is parallel to the direction of motion of the people walking. Here we see straight bands with different orientations. These bands appear to occlude each other. Each band corresponds to one person, and its orientation is given by the speed of walk and the direction of motion. Figure 19.1 (d) looks like a photo-finish photograph, similar to those used in sporting races. In both images (c) and (d), static objects appear as vertical stripes in (b) and horizontal stripes in (d).
One special sequence is when the image has a global motion with constant velocity . In such a case, we can write:
where is the image being translated, and and are constants. At time the image is translated by the vector as described by Equation 19.1. The pixel value at location at time will appear at time in location . This is what we see in Figure 19.1 (c) where the bands are created by moving pixels.
We use continuous values for , , and , and continuous images, , because it allows us to deal with any velocity values. This function also assumes that the brightness of the pixels does not change while the scene is moving (constant brightness assumption).
The constant brightness assumption is the initial hypothesis of most motion estimation algorithms. We will devote multiple chapters in Part Understanding Geometry to study motion in depth.
In general, sequences will be more complex, but the properties of a globally moving image are helpful to understand local properties in sequences. We can also write models for more complex sequences. For instance, a sequence containing a moving object over a static background can be written as:
19.3 Modeling sequences in the Fourier domain
The FT of a globally moving image is (using the shift property):
Figure 19.2: Fig (a) A sequence with one spatial dimension showing a static rectangular pulse. b) The rectangular pulse moves to the left at a speed and c) moving towards the left, . As we work with discretized signals, speed units are in pixels per frame.
Figure 19.2 shows the FT for a sequence with one spatial dimension, , that contains a blurry rectangular pulse moving at three different speeds towards the left. Figure 19.2 (a) shows a sequence when the pulse is static, and Figure 19.2 (d) shows its FT. Across the spatial frequency , the FT is approximately a sinc function.
Across the temporal frequency , as the signal is constant, its FT is a delta function. Therefore, the FT is a sinc function contained inside a delta wall in the line . Figure 19.2 (b) shows the same rectangular pulse moving towards the left, . Figure 19.2 (e) shows the sinc function but skewed along the frequency line . Note that this is not a rotation of the sinc function from Figure 19.2 (d) as the locations of the zeros lie at the same locations. Figure 19.2 (c) shows the pulse moving at a faster speed resulting in a larger skewing of its FT, Figure 19.2 (f).
The sinc function is the FT of a box kernel. In the continuous domain, the sinc function has the form:
We will discuss this further in Section 20.4.1.
19.4 Temporal filters
Linear spatio-temporal filters can be written as spatio-temporal convolutions between the input sequence and a convolutional kernel (impulse response). Discrete spatiotemporal filters have an impulse response . The extension from 2D filters to spatio-temporal filters does not have any additional complications. We can also classify filters as low-pass, high-pass, etc. But in the case of time, there is another attribute used to characterize filters: causality.
- Causal filters: These are filters with output variations that only depend on the past values of the input. This puts the following constraint: for all . This means that if the input is an impulse at , the output will only have non-zero values for . If this condition is satisfied, then the filter output will only depend on the input’s past for all possible inputs.
- Non-causal filters: When the output has a dependency on future inputs.
- Anti-causal filters: This is the opposite, when the output only depends on the future: for all .
Many filters are non-causal and have both causal and anti-causal components (e.g., a Gaussian filter). Note that non-causal filters cannot be implemented in practice and, therefore, any filter with an anti-causal component will have to be approximated by a purely causal filter by bounding the temporal support and shifting in time the impulse response.
In this chapter, we have written all the filters as convolutions. However, some filters are better described as difference equations (this is especially important in time). An example of a difference equation is:
The Heaviside step function, , is an infinite length function with the form
Most filters described by difference equations have an impulse response with infinite support. They are called IIR (Infinite Impulse Response) filters. IIR filters can be further classified as stable and unstable. Stable filters are the ones that given a bounded input, , produce a bounded output, . For this to happen, the impulse response has to be bounded. In unstable filters, the amplitude of the impulse response diverges to infinity. In the previous example, the filter is stable if and only if .
Let’s now describe some spatio-temporal filters.
19.4.1 Spatiotemporal Gaussian
As with the spatial case, we can define the same low-pass filters: the box filter, triangular filters, etc. As an example, let’s focus on the Gaussian filter. The spatio-temporal Gaussian is a trivial extension of the spatial Gaussian filter we have seen in @sec-spt_gaussian:
Where is the width of the Gaussian along the two spatial dimensions, and is the width in the temporal domain. As the units for and are unrelated, it does not make sense to set all the s to have the same value.
We can discretize the continuous Gaussian by taking samples and building a 3D convolutional kernel. We can also use the binomial approximation. The 3D Gaussian is separable, so it can be implemented efficiently as a convolutional cascade of 3 one-dimensional kernels. Figure 19.3 (a) shows a spatio-temporal Gaussian. The temporal Gaussian is a non-causal filter; therefore, it is not physically realizable. This is not a problem when processing a video stored in memory. However, if we are processing a streamed video, we will have to bound and shift the filter to make it causal, which will result in a delay in the output.
Figure 19.4 (a) shows one sequence, and Figure 19.4 (b) shows the sequence filtered with the Gaussian from Figure 19.3 (a). This Gaussian has a small spatial width, , and a large temporal width, , so the sequence is strongly blurred across time. The moving objects show motion blur and are strongly affected by the temporal blur, while the static background is only affected by the spatial width of the Gaussian.
Figure 19.3: Fig (a) Spatio-temporal Gaussian with and . b) Same Gaussian parameters but skewed by the velocity vector pixels/frame, c) and pixel/frame.
How could we create a filter that keeps sharp objects that move at some velocity while blurring the rest? Figure 19.4(c) shows the desired output of such a filter. The bottom image shows one frame for a sequence filtered with a kernel that keeps sharp objects moving left at 1 pixel/frame while blurring the rest. This filter can be obtained by skewing the Gaussian:
Figure 19.4: Fig (a) One frame from the input sequence and the space-time section (on top). b) Output when convolving with the Gaussian from Figure 19.3(a). c) Output of the convolution with Figure 19.3(b), and d) output of the convolution with Figure 19.3(c).
19.4.2 Temporal derivatives
Spatial derivatives were useful to find regions of image variation such as object boundaries. Temporal derivatives can be used to locate moving objects. We can approximate a temporal derivative for discrete signals as:
When implementing temporal filters it is important to use causal filters. A causal filter depends only on the present and past input samples.
As in the spatial case, it is useful to compute temporal derivatives of spatio-temporal Gaussians:
To answer that question, we will first assume the sequence contains a single object moving at a constant velocity. We will then compute the derivatives along , , and of the sequence and we will find out what particular linear combination of those derivatives makes the output go to zero only when the input sequence moves at a target velocity.
In the case of a moving image with velocity , the sequence is
This result is interesting because it shows that for a moving image there is a relationship between the temporal derivative of the sequence and the spatial derivatives a long the direction of motion. We can use this relationship to find a linear combination of the temporal and spatial derivatives so that the output is zero.
In fact, if we compute the gradient of the Gaussian along the vector :
we get a kernel that we can use as a spatiotemporal filter that will do exactly what we were looking for. Indeed, if we convolve it with the input sequence we get a zero output (using Equation 19.5):
The filter from Equation 19.6 is shown in Figure 19.5. As this filter is 3D, we show it as a sequence for different velocities. Each row in the figure corresponds to one particular velocity . In the example shown in Figure 19.5 (a), the Gaussian has a width of and has been discretized as a 3D array of size . Figures Figure 19.5 (b, c, and d) show the filter for different velocities: , , and .
Figure 19.5: Visualization of the space-time Gaussian. The Gaussian has a width of , and has been discretized as a 3D array of size . Each image shows one frame. a) Gaussian b) The partial derivative of the Gaussian with respect to . c) Derivative along pixels/frame. d) pixels/frame.
Figure 19.6 shows a different visualization of the same filter from Equation 19.6. Each image in Figure 19.6 shows a space-time section of the same spatiotemporal Gaussian derivatives as the ones shown in Figure 19.5. Both visualizations are equivalent and help to understand how the filter works.
Figure 19.6: Spatio-temporal Gaussian and derivatives. a) Gaussian with . b) Partial derivative with respect to . c) Partial derivative along , d) Partial derivative along .
Such a filter will cancel any objects moving at the velocity . By using different filters, each one computing derivatives along different space-time orientations, we can create output sequences where specific objects disappear, as shown in Figure 19.7. This filter is called a nulling filter [1].
Figure 19.7: (a) Input sequence. (b) Output to with . (c) pixels/frame. (d) pixel/frame.
Note that despite assuming that the sequence contained a single moving object when deriving the formulation for the nulling filter, the filter also works in sequences with multiple objects moving at different speeds, as shown in Figure 19.7. This is because the operations are local (the kernel has a small size), and the behavior will be correct if in a local image patch there is only one velocity present. In fact, it is easy to show that the method will also work if the sequence is a sum of several moving transparent layers.
19.5 Concluding Remarks
In this chapter, we have discussed different types of spatiotemporal filters used to analyze video. However, we have not presented how these filters can be used to estimate useful quantities such as velocity. We will devote several chapters in Part Understanding Motion to motion estimation.
[1]
T. Darrell, E. Simoncelli, On the use of ’nulling’ filters to separate transparent motions., in: Cvpr, 1993.








