1// ------------------------------------------------------------------------- 2// SWT - Scilab wavelet toolbox 3// Copyright (C) 2010-2014 Holger Nahrstaedt 4// 5// This program is free software; you can redistribute it and/or modify 6// it under the terms of the GNU General Public License as published by 7// the Free Software Foundation; either version 2 of the License, or 8// (at your option) any later version. 9// 10// This program is distributed in the hope that it will be useful, 11// but WITHOUT ANY WARRANTY; without even the implied warranty of 12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13// GNU General Public License for more details. 14// 15// You should have received a copy of the GNU General Public License 16// along with this program; if not, write to the Free Software 17// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18//------------------------------------------------------------------------- 19// 20// <-- NO CHECK ERROR OUTPUT --> 21 22 23// dwt2d Test 2 24 25// wenergy2 26a=rand(500,501,'normal'); 27 28[c,s]=wavedec2(a,3,'db2'); 29[cA1,cH1,cV1,cD1]=dwt2(a,'db2'); 30[cA2,cH2,cV2,cD2]=dwt2(cA1,'db2'); 31[cA3,cH3,cV3,cD3]=dwt2(cA2,'db2'); 32en=sum(c.*c); 33ea=sum(cA3.*cA3)*100/en; 34eh1=sum(cH1.*cH1)*100/en; 35eh2=sum(cH2.*cH2)*100/en; 36eh3=sum(cH3.*cH3)*100/en; 37ev1=sum(cV1.*cV1)*100/en; 38ev2=sum(cV2.*cV2)*100/en; 39ev3=sum(cV3.*cV3)*100/en; 40ed1=sum(cD1.*cD1)*100/en; 41ed2=sum(cD2.*cD2)*100/en; 42ed3=sum(cD3.*cD3)*100/en; 43[Ea,Eh,Ev,Ed]=wenergy2(c,s); 44[Eaa,Edetail]=wenergy2(c,s); 45eed1=eh1+ev1+ed1; 46eed2=eh2+ev2+ed2; 47eed3=eh3+ev3+ed3; 48 49assert_checkalmostequal ( Ea , ea , %eps,1e-10 ); 50assert_checkalmostequal ( Eh , [eh3 eh2 eh1] , %eps,1e-10 ); 51assert_checkalmostequal ( Ev , [ev3 ev2 ev1] , %eps, 1e-10 ); 52assert_checkalmostequal ( Ed , [ed3 ed2 ed1] , %eps, 1e-10); 53assert_checkalmostequal ( Eaa , ea , %eps, 1e-10 ); 54assert_checkalmostequal ( Edetail , [eed3 eed2 eed1] , %eps, 1e-10); 55 56 57 58clear cA1; 59clear cH1; 60clear cV1; 61clear cD1; 62clear cA2; 63clear cH2; 64clear cV2; 65clear cD2; 66clear cA3; 67clear cH3; 68clear cV3; 69clear cD3; 70clear c; 71clear s; 72clear eed1; 73clear eed2; 74clear eed3; 75clear eh1; 76clear eh2; 77clear eh3; 78clear ev1; 79clear ev2; 80clear ev3; 81clear ed1; 82clear ed2; 83clear ed3; 84