comparison util/Rice Wavelet Toolbox/daubcqf.m @ 78:f69ae88b8be5

added Rice Wavelet Toolbox with my modification, so it can be compiled on newer systems.
author Ivan Damnjanovic lnx <ivan.damnjanovic@eecs.qmul.ac.uk>
date Fri, 25 Mar 2011 15:27:33 +0000
parents
children
comparison
equal deleted inserted replaced
76:d052ec5b742f 78:f69ae88b8be5
1 function [h_0,h_1] = daubcqf(N,TYPE)
2 % [h_0,h_1] = daubcqf(N,TYPE);
3 %
4 % Function computes the Daubechies' scaling and wavelet filters
5 % (normalized to sqrt(2)).
6 %
7 % Input:
8 % N : Length of filter (must be even)
9 % TYPE : Optional parameter that distinguishes the minimum phase,
10 % maximum phase and mid-phase solutions ('min', 'max', or
11 % 'mid'). If no argument is specified, the minimum phase
12 % solution is used.
13 %
14 % Output:
15 % h_0 : Minimal phase Daubechies' scaling filter
16 % h_1 : Minimal phase Daubechies' wavelet filter
17 %
18 % Example:
19 % N = 4;
20 % TYPE = 'min';
21 % [h_0,h_1] = daubcqf(N,TYPE)
22 % h_0 = 0.4830 0.8365 0.2241 -0.1294
23 % h_1 = 0.1294 0.2241 -0.8365 0.4830
24 %
25 % Reference: "Orthonormal Bases of Compactly Supported Wavelets",
26 % CPAM, Oct.89
27 %
28
29 %File Name: daubcqf.m
30 %Last Modification Date: 01/02/96 15:12:57
31 %Current Version: daubcqf.m 2.4
32 %File Creation Date: 10/10/88
33 %Author: Ramesh Gopinath <ramesh@dsp.rice.edu>
34 %
35 %Copyright (c) 2000 RICE UNIVERSITY. All rights reserved.
36 %Created by Ramesh Gopinath, Department of ECE, Rice University.
37 %
38 %This software is distributed and licensed to you on a non-exclusive
39 %basis, free-of-charge. Redistribution and use in source and binary forms,
40 %with or without modification, are permitted provided that the following
41 %conditions are met:
42 %
43 %1. Redistribution of source code must retain the above copyright notice,
44 % this list of conditions and the following disclaimer.
45 %2. Redistribution in binary form must reproduce the above copyright notice,
46 % this list of conditions and the following disclaimer in the
47 % documentation and/or other materials provided with the distribution.
48 %3. All advertising materials mentioning features or use of this software
49 % must display the following acknowledgment: This product includes
50 % software developed by Rice University, Houston, Texas and its contributors.
51 %4. Neither the name of the University nor the names of its contributors
52 % may be used to endorse or promote products derived from this software
53 % without specific prior written permission.
54 %
55 %THIS SOFTWARE IS PROVIDED BY WILLIAM MARSH RICE UNIVERSITY, HOUSTON, TEXAS,
56 %AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
57 %BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
58 %FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RICE UNIVERSITY
59 %OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
60 %EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
61 %PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
62 %OR BUSINESS INTERRUPTIONS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
63 %WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
64 %OTHERWISE), PRODUCT LIABILITY, OR OTHERWISE ARISING IN ANY WAY OUT OF THE
65 %USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66 %
67 %For information on commercial licenses, contact Rice University's Office of
68 %Technology Transfer at techtran@rice.edu or (713) 348-6173
69
70 if(nargin < 2),
71 TYPE = 'min';
72 end;
73 if(rem(N,2) ~= 0),
74 error('No Daubechies filter exists for ODD length');
75 end;
76 K = N/2;
77 a = 1;
78 p = 1;
79 q = 1;
80 h_0 = [1 1];
81 for j = 1:K-1,
82 a = -a * 0.25 * (j + K - 1)/j;
83 h_0 = [0 h_0] + [h_0 0];
84 p = [0 -p] + [p 0];
85 p = [0 -p] + [p 0];
86 q = [0 q 0] + a*p;
87 end;
88 q = sort(roots(q));
89 qt = q(1:K-1);
90 if TYPE=='mid',
91 if rem(K,2)==1,
92 qt = q([1:4:N-2 2:4:N-2]);
93 else
94 qt = q([1 4:4:K-1 5:4:K-1 N-3:-4:K N-4:-4:K]);
95 end;
96 end;
97 h_0 = conv(h_0,real(poly(qt)));
98 h_0 = sqrt(2)*h_0/sum(h_0); %Normalize to sqrt(2);
99 if(TYPE=='max'),
100 h_0 = fliplr(h_0);
101 end;
102 if(abs(sum(h_0 .^ 2))-1 > 1e-4)
103 error('Numerically unstable for this value of "N".');
104 end;
105 h_1 = rot90(h_0,2);
106 h_1(1:2:N)=-h_1(1:2:N);