您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 其它行业文档 > 第5章-小波变换的matlab实现
1第4章小波变换的matlab实现21.Matlab中小波种类15种经典类小波:Harr小波、Morlet小波、Mexicanhat小波、Gaussian小波正交小波:db小波、对称小波、Coiflets小波、Meyer小波双正交小波查看命令wavemngr('read',1)3小波分析示例一维连续小波1.coefs=cwt(s,scale,’wname’)2.coefs=cwt(s,scale,’wname’,’plot’)c=cwt(noissin,1:48,'db4','plot');AbsoluteValuesofCa,bCoefficientsfora=12345...time(orspace)bscalesa10020030040050060070080090010001471013161922252831343740434601002003004005006007008009001000-1.5-1-0.500.511.54C=cwt(noissin,2:2:128,’db4’,’plot’)AbsoluteValuesofCa,bCoefficientsfora=246810...time(orspace)bscalesa100200300400500600700800900100021018263442505866748290981061141225图形接口方式(GUI)命令:wavemenu678一维离散小波分解命令:dwt格式:[cA1,cD1]=dwt(X,’wname’)[cA1,cD1]=dwt(X,Lo_D,Hi_D)举例:loadleleccum;s=leleccum(1:3920);ls=length(s);[cA1,cD1]=dwt(s,’db1’);90200400600800100012001400160018002000-30-20-100102030020040060080010001200140016001800200010020030040050060070080005001000150020002500300035004000100150200250300350400450500550原始信号低频系数高频系数10系数重构命令:upcoef格式:1.Y=upcoef(O,X,’wname’,N)2.Y=upcoef(O,X,’wname’,N,L)3.Y=upcoef(O,X,’Lo_R,Hi_R’,N)4.Y=upcoef(O,X,’Lo_R,Hi_R’,N,L)5.Y=upcoef(O,X,’wname’)6.Y=upcoef(O,X,Lo_R,Hi_R)O=‘a’低频,O=‘d’高频11举例:A1=upcoef('a','cA1','db1',1,ls);D1=upcoef('d','cD1','db1',1,ls);subplot(1,2,1);plot(A1);title('ApproximationA1')subplot(1,2,2);plot(D1);title('DetailD1')024630354045505560657075ApproximationA10246-80-60-40-20020406080DetailD112逆变换恢复信号命令:idwt格式:1.X=idwt(cA,cD,’wname’)2.X=idwt(cA,cD,Lo_R,Hi_R)3.X=idwt(cA,cD,’wname’,L)4.X=idwt(cA,cD,Lo_R,Hi_R,L)13举例:A0=idwt(cA1,cD1,'db1',ls);0500100015002000250030003500400010015020025030035040045050055014多尺度一维分解命令:wavedec格式:[C,L]=wavedec(X,N,’wname’)[C,L]=wavedec(X,N,Lo_D,Hi_D)15[C,L]=wavedec(s,3,'db1');05001000150020002500300035004000-2000200400600800100012001400160016低频系数提取命令:appcoef格式:1.A=appcoef(C,L,’wname’,N)2.A=appcoef(C,L,’wname’)3.A=appcoef(C,L,Lo_R,Hi_R,N)4.A=appcoef(C,L,Lo_R,Hi_R)17高频系数提取命令:detcoef格式:1.A=detcoef(C,L,N)2.A=detcoef(C,L)18举例cA3=appcoef(C,L,'db1',3);cD3=detcoef(C,L,3);cD2=detcoef(C,L,2);cD1=detcoef(C,L,1);02004006000500100015002000ApproximationcA30500100015002000-40-2002040DetailcD105001000-50050DetailcD20200400600-100-50050DetailcD319重构系数命令:wrcoef格式:1.X=wrcoef(‘type’,C,L,’wname’,N)2.X=wrcoef(‘type’,C,L,Lo_R,Hi_R,N)3.X=wrcoef(‘type’,C,L,’wname’)4.X=wrcoef(‘type’,C,L,Lo_R,Hi_R)type=‘a’低频,type=‘d’高频20A3=wrcoef('a',C,L,'db1',3);D1=wrcoef('d',C,L,'db1',1);D2=wrcoef('d',C,L,'db1',2);D3=wrcoef('d',C,L,'db1',3);010002000300040000200400600ApproximationA301000200030004000-40-2002040DetailD101000200030004000-40-2002040DetailD201000200030004000-40-2002040DetailD321重构原始信号命令:waverec格式:1.X=waverec(C,L,’wname’)2.X=waverec(C,L,Lo_R,Hi_R)例子:A0=waverec(C,L,’db1’);重构最大误差:Err=max(abs(s-A0))22originalLevel3ApproximationOriginalApproximation23图形接口方式(GUI)2425262728292.二维离散小波单尺度分解——dwt2格式:1.[cA1,cH1,cV1,cD1]=dwt2(X,’wname’)2.[cA1,cH1,cV1,cD1]=dwt2(X,Lo_D,Hi_D)cA1,cH1水平;cV1垂直;cD1对角应用:loadwbarb;figure(1);image(X);colormap(map);colorbar;[cA1,cH1,cV1,cD1]=dwt2(X,’bior3.7’)30重构系数命令:upcoef2格式:1.Y=upcoef2(O,X,’wname’,N,S)2.Y=upcoef2(O,X,Lo_R,Hi_R,N,S)3.Y=upcoef2(O,X,’wname’,N)4.Y=upcoef2(O,X,Lo_R,Hi_R,N)5.Y=upcoef2(O,X,’wname’)6.Y=upcoef2(O,X,Lo_R,Hi_R)O:‘a’低频;‘h’水平;‘v’垂直;‘d’对角31A1=upcoef2('a',cA1,'bior3.7',1);H1=upcoef2('h',cH1,'bior3.7',1);V1=upcoef2('v',cV1,'bior3.7',1);D1=upcoef2('d',cD1,'bior3.7',1);figure(2);colormap(map);subplot(2,2,1);image(wcodemat(A1,192));title('ApproximationA1')subplot(2,2,2);image(wcodemat(H1,192));title('HorizontalDetailH1')subplot(2,2,3);image(wcodemat(V1,192));title('VerticalDetailV1')subplot(2,2,4);image(wcodemat(D1,192));title('DiagonalDetailD1')32ApproximationA15010015020025050100150200250HorizontalDetailH15010015020025050100150200250VerticalDetailV15010015020025050100150200250DiagonalDetailD1501001502002505010015020025033二维逆变换命令:idwt2格式:1.X=idwt2(cA1,cH1,cV1,cD1,'bior3.7');2.X=idwt2(cA1,cH1,cV1,cD1,'bior3.7');3.X=idwt2(cA1,cH1,cV1,cD1,'bior3.7');4.X=idwt2(cA1,cH1,cV1,cD1,'bior3.7');应用:Xsyn=idwt2(cA1,cH1,cV1,cD1,'bior3.7');34多尺度二维小波命令:wavedec2格式:1.[C,S]=wavedec2(X,N,’wname’)2.[C,S]=wavedec2(X,N,Lo_D,Hi_D)35[C,S]=wavedec2(X,2,'bior3.7');%图像的多尺度二维小波分解36提取低频系数命令:appcoef2格式:1.A=appcoef2(C,S,’wname’,N)2.A=appcoef2(C,S,’wname’)3.A=appcoef2(C,S,Lo_R,Hi_R)4.A=appcoef2(C,S,Lo_R,Hi_R,N)cA2=appcoef2(C,S,'bior3.7',2);%从上面的C中提取第二层的低频系数37提取高频系数命令:detcoef2格式:A=detcoef2(‘type’,C,S,’wname’,N)说明:Type:’h’水平;‘v’垂直;‘d’对角cH2=detcoef2('h',C,S,2);cV2=detcoef2('v',C,S,2);cD2=detcoef2('d',C,S,2);cH1=detcoef2('h',C,S,1);cV1=detcoef2('v',C,S,1);cD1=detcoef2('d',C,S,1);38重构系数命令:wrcoef2格式:1.X=wrcoef2(‘type’,C,S,’wname’,N)2.X=wrcoef2(‘type’,C,S,Lo_R,Hi_R,N)3.X=wrcoef2(‘type’,C,S,’wname’)4.X=wrcoef2(‘type’,C,S,Lo_R,Hi_R,N)说明:Type:‘a’低频;’h’水平;‘v’垂直;‘d’对角39A2=wrcoef2('a',C,S,'bior3.7',2);H1=wrcoef2('h',C,S,'bior3.7',1);%重构第1、2层的高频信号V1=wrcoef2('v',C,S,'bior3.7',1);D1=wrcoef2('d',C,S,'bior3.7',1);H2=wrcoef2('h',C,S,'bior3.7',2);V2=wrcoef2('v',C,S,'bior3.7',2);D2=wrcoef2('d',C,S,'bior3.7',2);40Appro
本文标题:第5章-小波变换的matlab实现
链接地址:https://www.777doc.com/doc-1558759 .html