annotate util/Rice Wavelet Toolbox/daubcqf.m @ 143:8d866d96f006

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