hi everyone.. I am writing C programming for dwt. I used matlab to verify the equation and results. I wavelet transform the sound into 3 levels. and reconstruct again using idwt. In level 1, i managed to get back the original signal for reconstruction. But i failed in level 2 and 3 reconstruction. It does not produce the same result as a2 and a1. a1_rcon should be same as a1 and a2_rcon should be a2 but delayed. Anyone can guide me in this?
[h0,h1]=wfilters('db7','d');
[r0,r1]=wfilters('db7','r');
x=wavread('/home/coda/testing_sound/edited4.wav');
%................................................
%1st level decompostion
%................................................
%approximation
a1_d_c=conv(x,h0);
%a1_c2=wconv1(x,h0);
a1=downsample(a1_d_c,2);
%detail
d1_d_c=conv(x,h1);
%d1_c2=wconv1(x,h1);
d1=downsample(d1_d_c,2);
%................................................
%2nd level decompostion
%................................................
%approximation
a2_d_c=conv(a1,h0);
a2=downsample(a2_d_c,2);
%detail
d2_d_c=conv(d1,h1);
d2=downsample(d2_d_c,2);
%................................................
%3rd level decompostion
%................................................
%approximation
a3_d_c=conv(a2,h0);
a3=downsample(a3_d_c,2);
%detail
d3_d_c=conv(d2,h1);
d3=downsample(d3_d_c,2);
%................................................
%3rd level reconstruction
%................................................
%approximation
a3_r_u=upsample(a3,2);
a3_r_c=conv(a3_r_u,r0);
%detail
d3_r_u=upsample(d3,2);
d3_r_c=conv(d3_r_u,r1);
%approximation and detail addition
%form A1
a2_rcon=a3_r_c+d3_r_c;
%................................................
%2nd level reconstruction
%................................................
%approximation
a2_r_u=upsample(a2,2);
a2_r_c=conv(a2_r_u,r0);
%detail
d2_r_u=upsample(d2,2);
d2_r_c=conv(d2_r_u,r1);
%approximation and detail addition
%form A1
a1_rcon=a2_r_c+d2_r_c;
%................................................
%1st level reconstruction
%................................................
%approximation
a1_r_u=upsample(a1,2);
a1_r_c=conv(a1_r_u,r0);
%detail
d1_r_u=upsample(d1,2);
d1_r_c=conv(d1_r_u,r1);
%approximation and detail addition
%form A1
x_rcon=a1_r_c+d1_r_c;
|
|
0
|
|
|
|
Reply
|
moganesh
|
12/3/2010 7:52:04 AM |
|
The probem occurs because the reconstucted length in a particular level is not exactly equal to twice the length of a decomposed component for filters of length greater than 2. You must know how to manipulate those change in the length due to the change in the lengths of the wavelet filters used. To test, simply use db1 or haar's wavelet, there will be no reconstruction problem. Otherwise, you can try the wavedec and waverec functions to avoid such problems.
All the best.
Y. K. Singh
"moganesh " <moganesh@yahoo.com> wrote in message <ida7j4$9jb$1@fred.mathworks.com>...
> hi everyone.. I am writing C programming for dwt. I used matlab to verify the equation and results. I wavelet transform the sound into 3 levels. and reconstruct again using idwt. In level 1, i managed to get back the original signal for reconstruction. But i failed in level 2 and 3 reconstruction. It does not produce the same result as a2 and a1. a1_rcon should be same as a1 and a2_rcon should be a2 but delayed. Anyone can guide me in this?
>
> [h0,h1]=wfilters('db7','d');
> [r0,r1]=wfilters('db7','r');
>
>
> x=wavread('/home/coda/testing_sound/edited4.wav');
> %................................................
> %1st level decompostion
> %................................................
>
> %approximation
> a1_d_c=conv(x,h0);
> %a1_c2=wconv1(x,h0);
> a1=downsample(a1_d_c,2);
>
> %detail
> d1_d_c=conv(x,h1);
> %d1_c2=wconv1(x,h1);
> d1=downsample(d1_d_c,2);
>
> %................................................
> %2nd level decompostion
> %................................................
>
> %approximation
> a2_d_c=conv(a1,h0);
> a2=downsample(a2_d_c,2);
>
> %detail
> d2_d_c=conv(d1,h1);
> d2=downsample(d2_d_c,2);
>
> %................................................
> %3rd level decompostion
> %................................................
>
> %approximation
> a3_d_c=conv(a2,h0);
> a3=downsample(a3_d_c,2);
>
> %detail
> d3_d_c=conv(d2,h1);
> d3=downsample(d3_d_c,2);
>
> %................................................
> %3rd level reconstruction
> %................................................
>
> %approximation
> a3_r_u=upsample(a3,2);
> a3_r_c=conv(a3_r_u,r0);
>
> %detail
> d3_r_u=upsample(d3,2);
> d3_r_c=conv(d3_r_u,r1);
>
> %approximation and detail addition
> %form A1
> a2_rcon=a3_r_c+d3_r_c;
>
>
> %................................................
> %2nd level reconstruction
> %................................................
>
> %approximation
> a2_r_u=upsample(a2,2);
> a2_r_c=conv(a2_r_u,r0);
>
> %detail
> d2_r_u=upsample(d2,2);
> d2_r_c=conv(d2_r_u,r1);
>
> %approximation and detail addition
> %form A1
> a1_rcon=a2_r_c+d2_r_c;
>
> %................................................
> %1st level reconstruction
> %................................................
>
> %approximation
> a1_r_u=upsample(a1,2);
> a1_r_c=conv(a1_r_u,r0);
>
> %detail
> d1_r_u=upsample(d1,2);
> d1_r_c=conv(d1_r_u,r1);
>
> %approximation and detail addition
> %form A1
> x_rcon=a1_r_c+d1_r_c;
|
|
0
|
|
|
|
Reply
|
Yumnam
|
12/10/2010 11:54:06 AM
|
|
|
1 Replies
320 Views
(page loaded in 0.032 seconds)
|