DAUB Generates Daubechies filters. [H,G,RH,RG]=DAUB(NUM_COEFS) returns the coefficients of the orthonormal Daubechies wavelets with maximum number of vanishing moments and minimum phase. NUM_COEFS specifies the number of coefficients. The number of vanishing moments, that coincides with the number of zeros at z=-1, is equal to NUM_COEFS/2. H is the analysis lowpass filter, RH the synthesis lowpass filter, G the analysis highpass filter and RG the synthesis highpass filter. The choice of minimum phase leads to the most asymmetric scale function. NUM_COEFS must be even. See also: TRIGPOL, SYMLETS.
0001 function [h,g,rh,rg]=daub(num_coefs) 0002 0003 %DAUB Generates Daubechies filters. 0004 % 0005 % [H,G,RH,RG]=DAUB(NUM_COEFS) returns the coefficients of 0006 % the orthonormal Daubechies wavelets with maximum number 0007 % of vanishing moments and minimum phase. NUM_COEFS specifies 0008 % the number of coefficients. The number of vanishing moments, 0009 % that coincides with the number of zeros at z=-1, is equal 0010 % to NUM_COEFS/2. 0011 % 0012 % H is the analysis lowpass filter, RH the synthesis 0013 % lowpass filter, G the analysis highpass filter and 0014 % RG the synthesis highpass filter. 0015 % 0016 % The choice of minimum phase leads to the most asymmetric scale 0017 % function. 0018 % 0019 % NUM_COEFS must be even. 0020 % 0021 % See also: TRIGPOL, SYMLETS. 0022 0023 %-------------------------------------------------------- 0024 % Copyright (C) 1994, 1995, 1996, by Universidad de Vigo 0025 % 0026 % 0027 % Uvi_Wave is free software; you can redistribute it and/or modify it 0028 % under the terms of the GNU General Public License as published by the 0029 % Free Software Foundation; either version 2, or (at your option) any 0030 % later version. 0031 % 0032 % Uvi_Wave is distributed in the hope that it will be useful, but WITHOUT 0033 % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0034 % FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0035 % for more details. 0036 % 0037 % You should have received a copy of the GNU General Public License 0038 % along with Uvi_Wave; see the file COPYING. If not, write to the Free 0039 % Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 0040 % 0041 % Authors: Carlos Mosquera Nartallo 0042 % Nuria Gonzalez Prelcic 0043 % e-mail: Uvi_Wave@tsc.uvigo.es 0044 %-------------------------------------------------------- 0045 0046 if rem(num_coefs,2) 0047 error( 'Error: NUM_COEFS must be even!!!') 0048 end 0049 0050 N=num_coefs/2; 0051 0052 0053 poly=trigpol(N); %Calculate trigonometric polynomial 0054 0055 0056 zeros=roots(poly); %Calculate roots 0057 0058 % To construct rh for the minimum phase choice, we choose all the zeros 0059 % inside the unit circle. 0060 0061 modulus=abs(zeros); 0062 0063 j=1; 0064 for i=1:(2*(N-1)) 0065 if (modulus(i)<1) 0066 zerosinside(j)=zeros(i); 0067 j=j+1; 0068 end; 0069 end; 0070 0071 if j ~= N 0072 error('Error!!!'); % The number of zeros inside the unit circle 0073 % must be equal to the number of zeros outside 0074 % the unit circle. 0075 end 0076 0077 An=poly(1); 0078 0079 realzeros=[]; 0080 imagzeros=[]; 0081 numrealzeros=0; 0082 numimagzeros=0; 0083 0084 for i=1:(N-1) 0085 if (imag(zerosinside(i))==0) 0086 numrealzeros=numrealzeros+1; 0087 realzeros(numrealzeros)=zerosinside(i); 0088 else 0089 numimagzeros=numimagzeros+1; 0090 imagzeros(numimagzeros)=zerosinside(i); 0091 0092 end; 0093 0094 end; 0095 0096 0097 % Once ho is factorized in its zeros, it must be normalized multiplying by "cte". 0098 0099 cte=1; 0100 0101 for i=1:numrealzeros 0102 cte=cte*abs(realzeros(i)); 0103 end 0104 0105 for i=1:numimagzeros 0106 cte=cte*abs(imagzeros(i)); 0107 end 0108 0109 cte=sqrt(abs(An)/cte); 0110 0111 cte=0.5^N*sqrt(2)*cte; 0112 0113 % Construction of rh from its zeros 0114 0115 rh=[ 1 1]; 0116 0117 for i=2:N 0118 rh=conv(rh,[1 1]); 0119 end 0120 0121 for i=1:numrealzeros 0122 rh=conv(rh,[1 -realzeros(i)]); 0123 end 0124 0125 for i=1:2:numimagzeros 0126 rh=conv(rh,[1 -2*real(imagzeros(i)) abs(imagzeros(i))^2]); 0127 end 0128 0129 rh=cte*rh; 0130 [rh,rg,h,g]=rh2rg(rh);