解读matlab之小波库函数 联系客服

发布时间 : 星期四 文章解读matlab之小波库函数更新完毕开始阅读

function c=funreconstructindb2(ca1,cd1,tip) [h0,h1,h2,h3] = wfilters('db2'); N=length(ca1); w1=ca1; x1=cd1; w2=[w1;zeros(1,N)]; w3=w2(:)'; x2=[x1;zeros(1,N)]; x3=x2(:)'; y=conv(h2,w3)+conv(h3,x3); if(tip==1) N1=2*N-4; else N1=2*N-3; end c=y(4:N1+3);

图6

图7

但是你会发现边缘处的尺度函数系数和小波函数系数偏离的很远,这在阈值滤波时便会在边缘点处产生很大的误差。因为边缘点处没有完全用到4个滤波系数所致。

matlab小波库函数dwt中对这个问题的解决方案是边缘延拓,之前已作介绍,如图3所示。这里的描述借助图3的描述,依然假设x=[x(1) x(2) x(3) x(4) x(5) x(6) x(7)],计算

5

y=dwt(x,’db2’)。作边缘延拓后,得到图3所示结果。如图3所示,作卷积运算后,得到的项数共有16项,记为v(1)~v(16),但是作边缘取舍和下采样后得到项为z(2),z(4),z(6),z(8),z(10)。

接着的是重构过程,重构过程也是作卷积的过程,我们先对v(1)~v(16)项作下采样并作重构卷积运算,就可以清晰地知道z项的重构卷积运算是否达到重构效果。下图显示了重构过程。

图8

这里输入序列x的项数为奇数7,对于偶数项有稍许不同。

下面设x=[x(1) x(2) x(3) x(4) x(5) x(6)],作边缘延拓并作卷积运算得到的项数为15项,记为v(1)~v(15),再作边缘取舍和下采样后得到项为z(2),z(4),z(6),z(8)。下图显示了重构过程。

图9

从而得证。

下图程序是dwt和idwt函数的简单应用。

clear; load noissin; s=noissin(1:6); [ca1,cd1] = dwt(s,'db2'); ss = idwt(ca1,cd1,'db2'); plot(s); hold on; plot(ss,'r.'); hold off;

图10

6

图11

对图10所示程序,如果输入数据是奇数,重构后的点或多一个,不过最后两个点值一样,这也许是idwt函数考虑得不全面所致。如下图所示。

clear; load noissin; s=noissin(1:7); [ca1,cd1] = dwt(s,'db2'); ss = idwt(ca1,cd1,'db2'); plot(s); hold on; plot(ss,'r.'); hold off;

图12

7

图13

3 wavedec函数

wavedec函数是多尺度一维小波离散分解函数。

wavedec performs a multilevel one-dimensional wavelet analysis using either a specific wavelet ('wname') or a specific wavelet decomposition filters (Lo_D and Hi_D, see wfilters). [C,L] = wavedec(X,N,'wname') returns the wavelet decomposition of the signal X at level N, using 'wname'. N must be a strictly positive integer (see wmaxlev for more information). The output decomposition structure contains the wavelet decomposition vector C and the bookkeeping vector L. The structure is organized as in this level-3 decomposition example:

8