Because the CWT is a redundant transform and the CWT coefficients depend on the wavelet, it can be challenging to interpret the results.
To help you in interpreting CWT coefficients, it is best to start with a simple signal to analyze and an analyzing wavelet with a simple structure.
A signal feature that wavelets are very good at detecting is a discontinuity, or singularity. Abrupt transitions in signals result in wavelet coefficients with large absolute values.
For the signal create a shifted impulse. The impulse occurs at point 500.
x = zeros(1000,1); x(500) = 1;
For the wavelet, pick the Haar wavelet.
[~,psi,xval] = wavefun('haar',10); plot(xval,psi); axis([0 1 -1.5 1.5]); title('Haar Wavelet');
To compute the CWT using the Haar wavelet at scales 1 to 128, enter:
CWTcoeffs = cwt(x,1:128,'haar');
CWTcoeffs is a 128-by-1000 matrix. Each row of the matrix contains the
CWT coefficients for one scale. There are 128 rows because the
1:128. The column dimension of the matrix matches the
length of the input signal.
Recall that the CWT of a 1D signal is a function of the scale and position parameters. To produce a plot of the CWT coefficients, plot position along the x-axis, scale along the y-axis, and encode the magnitude, or size of the CWT coefficients as color at each point in the x-y, or time-scale plane.
You can produce this plot using
cwt with the optional input argument
cwt(x,1:128,'haar','plot'); colormap jet; colorbar;
The preceding figure was modified with text labels to explicitly show which colors indicate large and small CWT coefficients.
You can also plot the size of the CWT coefficients in 3D with
cwt(x,1:64,'haar','3Dplot'); colormap jet;
Examining the CWT of the shifted impulse signal, you can see that the set of large CWT coefficients is concentrated in a narrow region in the time-scale plane at small scales centered around point 500. As the scale increases, the set of large CWT coefficients becomes wider, but remains centered around point 500. If you trace the border of this region, it resembles the following figure.
This region is referred to as the cone of influence of the point t=500 for the Haar wavelet. For a given point, the cone of influence shows you which CWT coefficients are affected by the signal value at that point.
To understand the cone of influence, assume that you have a wavelet supported on [-C, C]. Shifting the wavelet by b and scaling by a results in a wavelet supported on [-Ca+b, Ca+b]. For the simple case of a shifted impulse, , the CWT coefficients are only nonzero in an interval around τ equal to the support of the wavelet at each scale. You can see this by considering the formal expression of the CWT of the shifted impulse.
For the impulse, the CWT coefficients are equal to the conjugated, time-reversed, and scaled wavelet as a function of the shift parameter, b. You can see this by plotting the CWT coefficients for a select few scales.
subplot(311) plot(CWTcoeffs(10,:)); title('Scale 10'); subplot(312) plot(CWTcoeffs(50,:)); title('Scale 50'); subplot(313) plot(CWTcoeffs(90,:)); title('Scale 90');
The cone of influence depends on the wavelet. You can find and plot the cone of influence
for a specific wavelet with
The next example features the superposition of two shifted impulses, . In this case, use the Daubechies' extremal phase wavelet with four
db4. The following figure shows the cone of influence
for the points 300 and 500 using the
Look at point 400 for scale 20. At that scale, you can see that neither cone of influence overlaps the point 400. Therefore, you can expect that the CWT coefficient will be zero at that point and scale. The signal is only nonzero at two values, 300 and 500, and neither cone of influence for those values includes the point 400 at scale 20. You can confirm this by entering:
x = zeros(1000,1); x([300 500]) = 1; CWTcoeffs = cwt(x,1:128,'db4'); plot(CWTcoeffs(20,:)); grid on;
Next, look at the point 400 at scale 80. At scale 80, the cones of influence for both points 300 and 500 include the point 400. Even though the signal is zero at point 400, you obtain a nonzero CWT coefficient at that scale. The CWT coefficient is nonzero because the support of the wavelet has become sufficiently large at that scale to allow signal values 100 points above and below to affect the CWT coefficient. You can confirm this by entering:
plot(CWTcoeffs(80,:)); grid on;
In the preceding example, the CWT coefficients became large in the vicinity of an abrupt change in the signal. This ability to detect discontinuities is a strength of the wavelet transform. The preceding example also demonstrated that the CWT coefficients localize the discontinuity best at small scales. At small scales, the small support of the wavelet ensures that the singularity only affects a small set of wavelet coefficients.
To demonstrate why the wavelet transform is so adept at detecting abrupt changes in the signal, consider a shifted Heaviside, or unit step signal.
x = [zeros(500,1); ones(500,1)]; CWTcoeffs = cwt(x,1:64,'haar','plot'); colormap jet;
Similar to the shifted impulse example, the abrupt transition in the shifted step function results in large CWT coefficients at the discontinuity. The following figure illustrates why this occurs.
In the preceding figure, the red function is the shifted unit step function. The black functions labeled A, B, and C depict Haar wavelets at the same scale but different positions. You can see that the CWT coefficients around position A are zero. The signal is zero in that neighborhood and therefore the wavelet transform is also zero because any wavelet integrates to zero.
Note the Haar wavelet centered around position B. The negative part of the Haar wavelet overlaps with a region of the step function that is equal to 1. The CWT coefficients are negative because the product of the Haar wavelet and the unit step is a negative constant. Integrating over that area yields a negative number.
Note the Haar wavelet centered around position C. Here the CWT coefficients are zero. The step function is equal to one. The product of the wavelet with the step function is equal to the wavelet. Integrating any wavelet over its support is zero. This is the zero moment property of wavelets.
At position B, the Haar wavelet has already shifted into the nonzero portion of the step function by 1/2 of its support. As soon as the support of the wavelet intersects with the unity portion of the step function, the CWT coefficients are nonzero. In fact, the situation illustrated in the previous figure coincides with the CWT coefficients achieving their largest absolute value. This is because the entire negative deflection of the wavelet oscillation overlaps with the unity portion of the unit step while none of the positive deflection of the wavelet does. Once the wavelet shifts to the point that the positive deflection overlaps with the unit step, there will be some positive contribution to the integral. The wavelet coefficients are still negative (the negative portion of the integral is larger in area), but they are smaller in absolute value than those obtained at position B.
The following figure illustrates two other positions where the wavelet intersects the unity portion of the unit step.
In the top figure, the wavelet has just begun to overlap with the unity portion of the unit step. In this case, the CWT coefficients are negative, but not as large in absolute value as those obtained at position B. In the bottom figure, the wavelet has shifted past position B and the positive deflection of the wavelet begins to contribute to the integral. The CWT coefficients are still negative, but not as large in absolute value as those obtained at position B.
You can now visualize how the wavelet transform is able to detect discontinuities. You can also visualize in this simple example exactly why the CWT coefficients are negative in the CWT of the shifted unit step using the Haar wavelet. Note that this behavior differs for other wavelets.
x = [zeros(500,1); ones(500,1)]; CWTcoeffs = cwt(x,1:64,'haar','plot'); colormap jet; % plot a few scales for visualization subplot(311); plot(CWTcoeffs(5,:)); title('Scale 5'); subplot(312); plot(CWTcoeffs(10,:)); title('Scale 10'); subplot(313); plot(CWTcoeffs(50,:)); title('Scale 50');
Next consider how the CWT represents smooth signals. Because sinusoidal oscillations are a
common phenomenon, this section examines how sinusoidal oscillations in the signal affect the
CWT coefficients. To begin, consider the
sym4 wavelet at a specific scale
superimposed on a sine wave.
Recall that the CWT coefficients are obtained by computing the product of the signal with the shifted and scaled analyzing wavelet and integrating the result. The following figure shows the product of the wavelet and the sinusoid from the preceding figure.
You can see that integrating over this product produces a positive CWT coefficient. That results because the oscillation in the wavelet approximately matches a period of the sine wave. The wavelet is in phase with the sine wave. The negative deflections of the wavelet approximately match the negative deflections of the sine wave. The same is true of the positive deflections of both the wavelet and sinusoid.
The following figure shifts the wavelet 1/2 of the period of the sine wave.
Examine the product of the shifted wavelet and the sinusoid.
You can see that integrating over this product produces a negative CWT coefficient. That results because the wavelet is 1/2 cycle out of phase with the sine wave. The negative deflections of the wavelet approximately match the positive deflections of the sine wave. The positive deflections of the wavelet approximately match the negative deflections of the sinusoid.
Finally, shift the wavelet approximately one quarter cycle of the sine wave.
The following figure shows the product of the shifted wavelet and the sinusoid.
Integrating over this product produces a CWT coefficient much smaller in absolute value than either of the two previous examples. That results because the negative deflection of the wavelet approximately aligns with a positive deflection of the sine wave. Also, the main positive deflection of the wavelet approximately aligns with a positive deflection of the sine wave. The resulting product looks much more like a wavelet than the other two products. If it looked exactly like a wavelet, the integral would be zero.
At scales where the oscillation in the wavelet occurs on either a much larger or smaller scale than the period of the sine wave, you obtain CWT coefficients near zero. The following figure illustrates the case where the wavelet oscillates on a much smaller scale than the sinusoid.
The product shown in the bottom pane closely resembles the analyzing wavelet. Integrating this product results in a CWT coefficient near zero.
The following example constructs a 60-Hz sine wave and obtains the CWT using the
t = linspace(0,1,1000); x = cos(2*pi*60*t); CWTcoeffs = cwt(x,1:64,'sym8','plot'); colormap jet;
Note that the CWT coefficients are large in absolute value around scales 9 to 21. You can find the pseudo-frequencies corresponding to these scales using the command:
freq = scal2frq(9:21,'sym8',1/1000);
Note that the CWT coefficients are large at scales near the frequency of the sine wave. You can clearly see the sinusoidal pattern in the CWT coefficients at these scales with the following code.
surf(CWTcoeffs); colormap jet; shading('interp'); view(-60,12);
The final example constructs a signal consisting of both abrupt transitions and smooth oscillations. The signal is a 2-Hz sinusoid with two introduced discontinuities.
N = 1024; t = linspace(0,1,1024); x = 4*sin(4*pi*t); x = x - sign(t - .3) - sign(.72 - t); plot(t,x); xlabel('t'); ylabel('x'); grid on;
Note the discontinuities near t=0.3 and t=0.7.
Obtain and plot the CWT using the
CWTcoeffs = cwt(x,1:180,'sym4'); imagesc(t,1:180,abs(CWTcoeffs)); colormap jet; axis xy; xlabel('t'); ylabel('Scales');
Note that the CWT detects both the abrupt transitions and oscillations in the signal. The abrupt transitions affect the CWT coefficients at all scales and clearly separate themselves from smoother signal features at small scales. On the other hand, the maxima and minima of the 2–Hz sinusoid are evident in the CWT coefficients at large scales and not apparent at small scales.
The following general principles are important to keep in mind when interpreting CWT coefficients.
Cone of influence— Depending on the scale, the
CWT coefficient at a point can be affected by signal values at points far removed. You
have to take into account the support of the wavelet at specific scales. Use
conofinf to determine the cone of influence. Not all wavelets are equal in
their support. For example, the Haar wavelet has smaller support at all scales than the
Detecting abrupt transitions— Wavelets are very useful for detecting abrupt changes in a signal. Abrupt changes in a signal produce relatively large wavelet coefficients (in absolute value) centered around the discontinuity at all scales. Because of the support of the wavelet, the set of CWT coefficients affected by the singularity increases with increasing scale. Recall this is the definition of the cone of influence. The most precise localization of the discontinuity based on the CWT coefficients is obtained at the smallest scales.
Detecting smooth signal features— Smooth signal features produce relatively large wavelet coefficients at scales where the oscillation in the wavelet correlates best with the signal feature. For sinusoidal oscillations, the CWT coefficients display an oscillatory pattern at scales where the oscillation in the wavelet approximates the period of the sine wave.
The basic algorithm for the continuous wavelet transform (CWT) is:
Take a wavelet and compare it to a section at the start of the original signal.
Calculate a number,
C, that represents how
closely correlated the wavelet is with this section of the signal. The larger the number
C is in absolute value, the more the similarity. This follows from
the fact the CWT coefficients are calculated with an inner product. See Inner Products for more information on how inner products measure similarity.
If the signal energy and the wavelet energy are equal to one,
C may be
interpreted as a correlation coefficient. Note that, in general, the signal energy does
not equal one and the CWT coefficients are not directly interpretable as correlation
As described in Continuous and Discrete Wavelet Transforms, the CWT coefficients explicitly depend on the analyzing wavelet. Therefore, the CWT coefficients are different when you compute the CWT for the same signal using different wavelets.
Shift the wavelet to the right and repeat steps 1 and 2 until you've covered the whole signal.
Scale (stretch) the wavelet and repeat steps 1 through 3.
Repeat steps 1 through 4 for all scales.