Lecture 19: Wavelet Compression of Time Series and Images
Total Page:16
File Type:pdf, Size:1020Kb
Lecture 19: Wavelet compression of time series and images c Christopher S. Bretherton Winter 2014 Ref: Matlab Wavelet Toolbox help. 19.1 Wavelet compression of a time series The last section of wavelet leleccum notoolbox.m demonstrates the use of wavelet compression on a time series. The idea is to keep the wavelet coefficients of largest amplitude and zero out the small ones. 19.2 Wavelet analysis/compression of an image Wavelet analysis is easily extended to two-dimensional images or datasets (data matrices), by first doing a wavelet transform of each column of the matrix, then transforming each row of the result (see wavelet image). The wavelet coeffi- cient matrix has the highest level (largest-scale) averages in the first rows/columns, then successively smaller detail scales further down the rows/columns. The ex- ample also shows fine results with 50-fold data compression. 19.3 Continuous Wavelet Transform (CWT) Given a continuous signal u(t) and an analyzing wavelet (x), the CWT has the form Z 1 s − t W (λ, t) = λ−1=2 ( )u(s)ds (19.3.1) −∞ λ Here λ, the scale, is a continuous variable. We insist that have mean zero and that its square integrates to 1. The continuous Haar wavelet is defined: 8 < 1 0 < t < 1=2 (t) = −1 1=2 < t < 1 (19.3.2) : 0 otherwise W (λ, t) is proportional to the difference of running means of u over successive intervals of length λ/2. 1 Amath 482/582 Lecture 19 Bretherton - Winter 2014 2 In practice, for a discrete time series, the integral is evaluated as a Riemann sum using the Matlab wavelet toolbox function cwt. An example is given on the class web page wavelet leleccum cwt. 19.4 Other wavelets; the Matlab wavelet tool- box Haar wavelets are simple but depending on the application, other wavelets are better choices. For instance, Haar wavelets take a linear trend (which is smooth) and subdivide it into both average and detail components. The db2 wavelet is designed to put linear trends into only the average component, so is more efficient for decomposing data with linear gradients, while maintaining mutual orthonormality of wavelets and scaling vectors. The level-1 db2 wavelets are: 1 W1 = [β1; β2; β3; β4; 0; 0; 0; 0;:::; 0; 0] 1 W2 = [0; 0; β1; β2; β3; β4; 0; 0;:::; 0; 0] (19.4.1) . where p p p β = (1 − 3)=4 2 = −:13; β = β 3 = −:22; 1 p 2 p 1 p β3 = −β4 3 = :84; β4 = −(1 + 3)=4 2 = −:48: (19.4.2) and the scaling vectors have the form 1 W1 = [−β4; β3; −β2; β1; 0; 0; 0; 0;:::; 0; 0] 1 W2 = [0; 0; −β4; β3; −β2; β1; 0; 0;:::; 0; 0] (19.4.3) . Another advantage of the db2 wavelet over the Haar wavelet is that it acts as a tighter band pass filter in separating information from different octaves of scale. The Matlab toolbox supports a variety of wavelet types; see documentation for more information. 19.5 Boundary conditions Unlike Haar, other wavelets always involve weighting more than two neighbor- ing elements to create the average and detail vectors. This means assumptions need to be made to compute the coefficients at the edges of the data. Because wavelets have compact support, these assumptions are localized near the bound- aries (but propagate inward for higher analysis levels). By default the Matlab wavelet toolbox pads the data with zeros to compute wavelet coefficients near boundaries; this can be a poor choice. A better assumption is to extend the data Amath 482/582 Lecture 19 Bretherton - Winter 2014 3 by a copy with the indices reversed; this avoids introducing artificial boundary discontinuities. The extended data looks as follows: uext = : : : u4; u3; u2ju1; u2; : : : uN juN−1; uN−2;::: (19.5.1) This can be invoked using dwtmode('sym')..