⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dfilters.m

📁 PDTDFB toolbox The filter bank is described in: The Shiftable Complex Directional Pyramid—Pa
💻 M
📖 第 1 页 / 共 2 页
字号:
function [h0, h1] = dfilters(fname, type)
% DFILTERS	Generate diamond 2D filters
%
%	[h0, h1] = dfilters(fname, type)
%
% Input:
%  fname:	Filter name.  Available 'fname' are:
%       'haar':     the "Haar" filters
%
%       '5-3':      McClellan transformed of 5-3 filters
%
%       'cd','9-7': McClellan transformed of 9-7 filters (Cohen and Daubechies)
%
%       'pkvaN':   length N ladder filters by Phong et al. (N = 6, 8, 12)
%                   'pkva6', 'pkva8', 'pkva12', 'pkva'
%
%       'tk', 'tkN' : Generalized McClellan transformation method (Tay and
%       Kingsburry) (N = 7, 11 default 'tk' 5) (Require image processing toolbox)
%
%       'lat8','lat10','lat17' : the filter that can be implement by lattice structure
%       size 8*9 and size 10*11 and 17*18 respectively
%       ( see Chapter 6 , 'The multiresolution DFBs' PhD dissertation)
%
%       'optim9', 'optim11'   : The coefficient of diamond filter design by
%       optimizaition method 
%       ( see Chapter 6 , 'The multiresolution DFBs' PhD dissertation)
%
%       'meyer' : meyer type diamond filter bank
%       'meyerh2''meyerh3' : meyer type fan fb for the second level of the dual dfb
%
%  type:	'd' or 'r' for decomposition or reconstruction filters
%
% Output:
%
%   h0, h1:	diamond filter pair (lowpass and highpass)
%
% See also : LPFILTERS, WFILTERS
% References
% 
% Note
%   20/7/07 : clean up this file, remove old option


% To test those filters (for the PR condition for the FIR case), verify that:
% conv2(h0, modulate2(h1, 'b')) + conv2(modulate2(h0, 'b'), h1) = 2
% (replace + with - for even size filters)
%
% To test for orthogonal filter
% conv2(h, reverse2(h)) + modulate2(conv2(h, reverse2(h)), 'b') = 2

% The diamond-shaped filter pair
switch fname
    case {'haar'} %-------------------------------------------------------
        if lower(type(1)) == 'd'
            h0 = [1, 1] / sqrt(2);
            h1 = [-1, 1] / sqrt(2);
        else
            h0 = [1, 1] / sqrt(2);
            h1 = [1, -1] / sqrt(2);
        end

    case {'5-3', '5/3'}     % McClellan transformed of 5-3 filters %------
        % 1D prototype filters: the '5-3' pair
        [h0, g0] = pfilters('5-3');

        if lower(type(1)) == 'd'
            h1 = modulate2(g0, 'c');
        else
            h1 = modulate2(h0, 'c');
            h0 = g0;
        end

        % Use McClellan to obtain 2D filters
        t = [0, 1, 0; 1, 0, 1; 0, 1, 0] / 4;	% diamond kernel
        h0 = mctrans(h0, t);
        h1 = mctrans(h1, t);
    case {'cd', '9-7', '9/7'}	    % ------------------------------------
        % 1D prototype filters: the '9-7' pair
        [h0, g0] = pfilters('9-7');

        if lower(type(1)) == 'd'
            h1 = modulate2(g0, 'c');
        else
            h1 = modulate2(h0, 'c');
            h0 = g0;
        end

        % Use McClellan to obtain 2D filters
        t = [0, 1, 0; 1, 0, 1; 0, 1, 0] / 4;	% diamond kernel
        h0 = mctrans(h0, t);
        h1 = mctrans(h1, t);

    case {'pkva6', 'pkva8', 'pkva12', 'pkva'}
        % Filters from the ladder structure

        % Allpass filter for the ladder structure network
        beta = ldfilter(fname);

        % Analysis filters
        [h0, h1] = ld2quin(beta);

        % Normalize norm
        h0 = sqrt(2) * h0;
        h1 = sqrt(2) * h1;

        % Synthesis filters
        if lower(type(1)) == 'r'
            f0 = modulate2(h1, 'b');
            f1 = modulate2(h0, 'b');

            h0 = f0;
            h1 = f1;
        end
    case {'lat8'} % lattice structure filter
        % load mat\lat8.mat
        h0 =  10^(-3)*[...
            0         0         0   19.6853  -20.9112         0         0         0         0;
            0         0   41.3906  -43.9682   -1.7544   12.2187         0         0         0;
            0   17.2361  -18.3095 -159.9463    8.0327  -69.3194   69.9947         0         0;
            -4.5969    4.8832 -150.2817  -29.9456  360.8494  -69.4293  -37.2543    4.0663   0;
            0   35.3025    2.0879  306.9457  789.0718  193.0575   -5.6809   -5.1280   -4.8274;
            0         0  -62.0192  -67.9865  170.3598    0.3474   19.2276   18.1004         0;
            0         0         0  -25.7092  -13.9653   46.1728   43.4661         0         0;
            0         0         0         0   21.9597   20.6724         0         0         0];

        h1 =  -10^(-3)*[...
            0         0         0   20.6724  -21.9597         0         0         0         0;
            0         0   43.4661  -46.1728  -13.9653   25.7092         0         0         0;
            0   18.1004  -19.2276    0.3474 -170.3598  -67.9865   62.0192         0         0;
            -4.8274    5.1280   -5.6809 -193.0575  789.0718 -306.9457    2.0879  -35.3025   0;
            0    4.0663   37.2543  -69.4293 -360.8494  -29.9456  150.2817    4.8832    4.5969;
            0         0   69.9947   69.3194    8.0327  159.9463  -18.3095  -17.2361         0;
            0         0         0   12.2187    1.7544  -43.9682  -41.3906         0         0;
            0         0         0         0  -20.9112  -19.6853         0         0         0];

        if lower(type(1)) == 'd'
        else
            h0 = h0(end:-1:1,end:-1:1);
            h1 = h1(end:-1:1,end:-1:1);
        end

    case {'lat10'} % lattice structure filter
        % diamond filter of size 10*11
        H(:,:,1) =  -10^(-3)*[...
            0         0         0         0   -0.0113   -0.1134         0         0         0         0         0;
            0         0         0   -0.1516   -1.5162    0.4113   -2.8702         0         0         0         0;
            0         0    0.3303    3.3033   -2.7298  -14.2898   15.4026  -18.4426         0         0         0;
            0    1.2795   12.7954    2.4510   72.2226  -35.9680   94.8643  102.1411   -9.0141         0         0;
            0.4726    4.7258    0.9398    8.3444 -102.0748 -534.4668 -278.7716   15.6555   -7.0806    2.3563    0;
            0    0.9413    1.5834    1.4902   -5.3506 -283.2854  -70.8236   72.2972   -7.0081   -9.9486    0.9949;
            0         0   -4.6912  -49.6634   20.4799   -1.6936   60.4236  -16.0867  -26.9360    2.6936         0;
            0         0         0   -7.1195   11.0385  -18.5912   -0.8792   -6.9540    0.6954         0         0;
            0         0         0         0    1.8227    1.2877    3.1917   -0.3192         0         0         0;
            0         0         0         0         0    0.2387   -0.0239         0         0         0         0];

        H(:,:,2) = -10^(-3)*[...
            0         0         0         0    0.0239    0.2387         0         0         0         0         0;
            0         0         0    0.3192    3.1917   -1.2877    1.8227         0         0         0         0;
            0         0   -0.6954   -6.9540    0.8792  -18.5912  -11.0385   -7.1195         0         0         0;
            0   -2.6936  -26.9360   16.0867   60.4236    1.6936   20.4799   49.6634   -4.6912         0         0;
            -0.9949   -9.9486    7.0081   72.2972   70.8236 -283.2854    5.3506    1.4902   -1.5834    0.9413   0;
            0   -2.3563   -7.0806  -15.6555 -278.7716  534.4668 -102.0748   -8.3444    0.9398   -4.7258    0.4726;
            0         0    9.0141  102.1411  -94.8643  -35.9680  -72.2226    2.4510  -12.7954    1.2795         0;
            0         0         0   18.4426   15.4026   14.2898   -2.7298   -3.3033    0.3303         0         0;
            0         0         0         0    2.8702    0.4113    1.5162   -0.1516         0         0         0;
            0         0         0         0         0    0.1134   -0.0113         0         0         0         0];

        if lower(type(1)) == 'd'
            h0 = sqrt(2)*squeeze(H(:,:,1));
            h1 = sqrt(2)*squeeze(H(:,:,2));
        else
            h0 = sqrt(2)*squeeze(H(end:-1:1,end:-1:1,1));
            h1 = sqrt(2)*squeeze(H(end:-1:1,end:-1:1,2));
        end
        
    case {'lat17'} % lattice structure filter
        % diamond filter of size 17*18
        % old mat file        load Dlat8.mat
        H(:,:,1) = -10^(-3)*[...
            0         0         0         0         0         0         0         0   -0.0000    0.0001         0         0         0         0         0         0         0         0;
            0         0         0         0         0         0         0    0.0006   -0.0117    0.0003   -0.0061         0         0         0         0         0         0         0;
            0         0         0         0         0         0   -0.0110    0.2152   -0.0222    0.5309   -0.0037    0.1217         0         0         0         0         0         0;
            0         0         0         0         0    0.0532   -1.0396    0.1759   -5.2824    0.0495   -5.3705   -0.0193   -0.6195         0         0         0         0         0;
            0         0         0         0    0.0335   -0.6552    0.4122    1.9268    2.4833   -0.3302    2.9904  -12.9126    0.3894   -2.5618         0         0         0         0;
            0         0         0   -0.3541    6.9242   -1.8345   34.0051   -3.3201    2.4341   -6.1550   21.5160    4.2553    1.9084    1.1577   -1.5432         0         0         0;
            0         0   -0.3543    6.9277   -3.8687   15.3707   -9.7280  -74.0358   16.5652  -15.8648   28.5357  -48.3298    3.3437   12.5238    0.6338    0.6987         0         0;
            0   -0.0337    0.6580    0.2788  -14.7836    9.2159    0.1277   22.9984   53.0882 -124.7117  125.1335   27.6191  -38.1974    2.9189    2.3636   -0.2786    0.0043         0;
            0.0006   -0.0109    2.0715   -4.7297   16.0513  -26.7438  -90.0447 -135.3339 -392.4347 -706.4825  -52.9402  104.0566   -6.2630    5.1932   -3.4552   -1.4591   -0.0077   -0.0004;
            0   -0.0061   -0.3951   -2.9340    3.9272   18.6087   -1.3045   32.1750 -123.5876 -413.2989   98.3748  140.8226   -3.6557  -18.1300   -1.1304    0.4608    0.0236         0;
            0         0   -0.9908    0.8988  -18.2650    3.6855   -4.8774   21.5462  119.7541   11.9448  121.0278  -13.3458  -53.4407   -0.4933    5.0792    0.2598         0         0;
            0         0         0    2.1884    1.6417   -5.1248    5.1058  -61.0996  -13.2142   -0.2612   -2.1187  -45.6162   -1.3450    6.9575    0.3558         0         0         0;
            0         0         0         0    3.6329    0.5523   16.3976    3.9962   -7.6154    1.8079   -1.8254   -0.2971    1.8737    0.0958         0         0         0         0;
            0         0         0         0         0    0.8785   -0.0273    7.2650    0.0743    4.4512    0.1649   -0.6016   -0.0308         0         0         0         0         0;
            0         0         0         0         0         0   -0.1726   -0.0052   -0.7004   -0.0294   -0.1373   -0.0070         0         0         0         0         0         0;
            0         0         0         0         0         0         0    0.0087    0.0004    0.0151    0.0008         0         0         0         0         0         0         0;
            0         0         0         0         0         0         0         0   -0.0001   -0.0000         0         0         0         0         0         0         0         0 ];

        H(:,:,2) = -10^(-3)*[...
            0         0         0         0         0         0         0         0    0.0000   -0.0001         0         0         0         0         0         0         0         0;
            0         0         0         0         0         0         0   -0.0008    0.0151   -0.0004    0.0087         0         0         0         0         0         0         0;
            0         0         0         0         0         0    0.0070   -0.1373    0.0294   -0.7004    0.0052   -0.1726         0         0         0         0         0         0;
            0         0         0         0         0    0.0308   -0.6016   -0.1649    4.4512   -0.0743    7.2650    0.0273    0.8785         0         0         0         0         0;
            0         0         0         0   -0.0958    1.8737    0.2971   -1.8254   -1.8079   -7.6154   -3.9962   16.3976   -0.5523    3.6329         0         0         0         0;
            0         0         0   -0.3558    6.9575    1.3450  -45.6162    2.1187   -0.2612   13.2142  -61.0996   -5.1058   -5.1248   -1.6417    2.1884         0         0         0;
            0         0   -0.2598    5.0792    0.4933  -53.4407   13.3458  121.0278  -11.9448  119.7541  -21.5462   -4.8774   -3.6855  -18.2650   -0.8988   -0.9908         0         0;
            0   -0.0236    0.4608    1.1304  -18.1300    3.6557  140.8226  -98.3748 -413.2989  123.5876   32.1750    1.3045   18.6087   -3.9272   -2.9340    0.3951   -0.0061         0;
            0.0004   -0.0077    1.4591   -3.4552   -5.1932   -6.2630 -104.0566  -52.9402  706.4825 -392.4347  135.3339  -90.0447   26.7438   16.0513    4.7297    2.0715    0.0109    0.0006;
            0   -0.0043   -0.2786   -2.3636    2.9189   38.1974   27.6191 -125.1335 -124.7117  -53.0882   22.9984   -0.1277    9.2159   14.7836    0.2788   -0.6580   -0.0337         0;
            0         0   -0.6987    0.6338  -12.5238    3.3437   48.3298   28.5357   15.8648   16.5652   74.0358   -9.7280  -15.3707   -3.8687   -6.9277   -0.3543         0         0;
            0         0         0    1.5432    1.1577   -1.9084    4.2553  -21.5160   -6.1550   -2.4341   -3.3201  -34.0051   -1.8345   -6.9242   -0.3541         0         0         0;
            0         0         0         0    2.5618    0.3894   12.9126    2.9904    0.3302    2.4833   -1.9268    0.4122    0.6552    0.0335         0         0         0         0;
            0         0         0         0         0    0.6195   -0.0193    5.3705    0.0495    5.2824    0.1759    1.0396    0.0532         0         0         0         0         0;
            0         0         0         0         0         0   -0.1217   -0.0037   -0.5309   -0.0222   -0.2152   -0.0110         0         0         0         0         0         0;
            0         0         0         0         0         0         0    0.0061    0.0003    0.0117    0.0006         0         0         0         0         0         0         0;
            0         0         0         0         0         0         0         0   -0.0001   -0.0000         0         0         0         0         0         0         0         0];

        if lower(type(1)) == 'd'
            h0 = squeeze(H(:,:,1));
            h1 = squeeze(H(:,:,2));
        else
            h0 = squeeze(H(end:-1:1,end:-1:1,1));
            h1 = squeeze(H(end:-1:1,end:-1:1,2));
        end

    case {'tk','tk7','tk11'} % --------------------------------------------
        % Filter by DB Tay and Kingsburry method
        switch fname
            case {'tk7'}
                N = 7;
            case {'tk11'}
                N = 11;
            otherwise
                N = 5;
        end
        % calculate the transformation matrix , internal function
        h_trans = trans_matrix(N);
        % the maxflat lagrange halfband 3-5
        h = [ 0.2500    0.5000    0.2500 ];
        f = [-0.1250    0.2500    0.7500    0.2500   -0.1250];
        % Use Mcclellan transform
        if lower(type(1)) == 'd'
            h0 = sqrt(2)*ftrans2(h,h_trans);
            f0 = sqrt(2)*ftrans2(f,h_trans);
            % two diamond filter h0,f0, h0*f0 is nyquist Q
            h1 = modulate2(f0,'b');
        else

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -