It is correct that we can directly relate those coefficients to the signal? Amplitude of the coefficient corresponds to amplitude with which the wavelet occurs in the signal (y axis), and position of the coefficient corresponds to the time (x axis). Or is there something in between we need to consider?
After the DWT the final lvl1 approximation remains. Does it make sense to not visualize the relation of the detail coefficients with the original signal, but instead with the original signal minus the lvl1 approximation? (I know that I would most likely also see the relation between coefficients and signal without doing this, see e.g. plots below. It's just for it this makes sense or not. Should it makes sense for lvl1 detail coefficients then it might also make sense for lvl2 detail coefficients to be compared to the original signal minus the lvl2 approximation, right?). An example:
# Reconstruction of signal using just lvl1 approximation approx_lvl1 = pywt.waverec(coeffs[:-6] + [None] * 6, w) # interpolate to original amount of samples (necessary due to numeric solution of transformation not yielding same amount of values) approx_lvl1_interp = np.interp(x=np.arange(0, 1024), xp=np.linspace(0, 1024, len(approx_lvl1)), fp=approx_lvl1) x_without_lvl1approx = x - approx_lvl1_interp
The direct visualization of the relation between detail coefficients and signal I use isjust plots both the signal and the coefficients on an x axis of [0,1]. This should conceptually be valid, but I am unsure if I would actually need an offset towards the margins (e.g. first and last coefficient of the vector not being positioned at the very beginning or end of the signal):
def reconstruction_stem(yyy, **kwargs): """Plot coefficient vector on x [0,1] independently of amount of values it contains.""" plt.stem(np.linspace(0, 1, len(yyy)), yyy, **kwargs) reconstruction_plot(x, color='orange') reconstruction_plot(x_without_lvl1approx, color='red') reconstruction_stem(coeffs[1]) plt.legend(['Original signal', 'Original signal - lvl1 approximation', 'Detail coefficients'])
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
geekoverdose
- 251
- 1
- 2
- 7