Filter löschen
Filter löschen

How to reconstruction multilevel wavelet (DWT)

5 Ansichten (letzte 30 Tage)
grandong oblong
grandong oblong am 2 Mär. 2020
Beantwortet: Binaya am 21 Aug. 2024 um 17:29
I want to reconstruction a2, d2, and d1 to be x, but length of a2, d2 ,and d1 are different. How to solve it?. Please help me
x = [5 7 8 9];
[LoD,HiD,LoR,HiR] = wfilters('db2');
% Decomposition
% level 1
cA1 = dyaddown(conv(x,LoD));
cD1 = dyaddown(conv(x,HiD));
% level 2
cA2 = dyaddown(conv(cA1,LoD));
cD2 = dyaddown(conv(cA1,HiD));
%Reconstruction
a1 = conv(dyadup(cA1),LoR);
d1 = conv(dyadup(cD1),HiR);
a2 = conv(dyadup((conv(dyadup(cA2),LoR))),LoR);
d2 = conv(dyadup((conv(dyadup(cD2),HiR))),LoR);
% a2+d2+d1 = x

Antworten (1)

Binaya
Binaya am 21 Aug. 2024 um 17:29
Hi grandong
I understand that you would like to reconstruct your signal from wavelet coefficients. You can use "wavedec" and "waverec" functions to decompose and reconstruct your signal instead of using "dyadup" and "dyaddown" functions.
Here is a sample code snippet to decompose a signal, calculate coefficients and reconstruct the signal:
% Original signal
x = [5 7 8 9]
x = 1x4
5 7 8 9
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% Wavelet decomposition using 'db2'
waveletName = 'db2';
level = 2;
% Decompose the signal
[c, l] = wavedec(x, level, waveletName);
% Extract coefficients
cA1 = appcoef(c, l, waveletName, level-1)
cA1 = 1x3
7.7782 8.8989 12.3744
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
cD1 = detcoef(c, l, level-1)
cD1 = 1x3
-1.2247 0.1294 0.6124
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% Reconstruct the signal
xReconstructed = waverec(c, l, waveletName)
xReconstructed = 1x4
5.0000 7.0000 8.0000 9.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
You can refer to the following documentation links for more details on:
  1. wavedec: https://www.mathworks.com/help/wavelet/ref/wavedec.html
  2. wacerec: https://www.mathworks.com/help/wavelet/ref/waverec.html
  3. appcoef: https://www.mathworks.com/help/wavelet/ref/appcoef.html
  4. detcoef: https://www.mathworks.com/help/wavelet/ref/detcoef.html
I hope this answers your query.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by