📄 syntw2d.m
字号:
function sy = syntw2d(an,sl,sh,levs)
%Routine to reconstruct the 2-D signal from its multilevel DWT, using
%an odd length or whole sample symmetric (WSS) separable biorthogonal
%filter bank. Symmetric extension used to extend the subbands. This is
%complemetary function to the analysis routine 'analw2d'.
%
%sy = syntw2d(an,lpf,hpf,L) reconstructs a 2-D image from its DWT, 'an',
%which could be the output of the routine 'analw2d'.
%The image is assumed to be decomposed to L levels. The WSS filter
%bank used comprises of sl and sh. If this corresponds to the
%analysis filter bank used for decomposition then you get perfect
%reconstruction. The reconstructed image is returned as a 2-D array,
%sy.
%
%sy = syntw2d(an,fopt,L) reconstructs a 2-D array from its DWT, 'an',
%which could be the output of the routine 'analw2d'.
%The image is assumed to be decomposed to L levels. fopt chooses a
%WSS synthesis filter bank provided in the routine. If this corresponds
%to the analysis filter bank used for the decomposition then you get
%perfect reconstruction. The reconstructed image is returned as a 2-D
%array, 'sy'.
%
%The input variables are
%an : L-level DWT of a 2-D array
%lpf, hpf: these two filters define the synthesis filter bank
%OR
%fopt :Takes the values of 1 and 2 and correspond to the 7/9 and
% 9/7 filter banks used by FBI for their fingerprint compression
% scheme. They correspond to options 1 and 2 in the analysis
% routine respectively.
%L : Number of levels of decomposition and hence synthesis.
%
%The output 'sy' can be plotted using the commands 'image' or 'imagesc'
%and the command 'colormap(gray)' to specify the color map. Please refer
%to online help for more information.
%
%The final result of the synthesis procedure is plotted at the end
%of the routine anyway.
%
%Refer to Chapter 4 for information on biorthogonal wavelet
%decomposition and reconstruction and 2-D separable wavelet transform.
%
%Author: Ajit S. Bopardikar
%Copyright (c) 1998 by Addison Wesley Longman, Inc.
%
num = nargin; %number of input arguments
if (num ==3)
levs = sh;
if(sl == 1)
sl =[-0.06453888262894 -0.04068941760956 0.41809227322221 0.78848561640566 0.41809227322221 -0.04068941760956 -0.06453888262894];
sh =[0.03782845550700 0.02384946501938 -0.11062440441840 -0.37740285561265 0.85269867900940 -0.37740285561265 -0.11062440441840 0.02384946501938 0.03782845550700];
elseif (sl >=2)
if (sl > 2)
fprintf('fopt chosen to be greater than 2. Using fopt=2 instead\n');
end;
sl =[0.03782845550700 -0.02384946501938 -0.11062440441842 0.37740285561265 0.85269867900940 0.37740285561265 -0.11062440441842 -0.02384946501938 0.03782845550700];
sh =[0.06453888262894 -0.04068941760956 -0.41809227322221 0.78848561640566 -0.41809227322221 -0.04068941760956 0.06453888262894];
end %end inner if
end %end if
[m,n] = size(an);
%Determine the dimension of each low-low subband
ms = [m]; %initialize the arrays
ns = [n]; %initialize the arrays
%for rows
for i=1:(levs-1)
if (m/2 == round(m/2)) %even number of rows
m = m/2;
else %odd number of rows
if (length(sl) > length(sh))
m = floor(m/2);
else
m = ceil(m/2);
end %end inner if
end %end if - this finishes the rows
if(n/2 == round(n/2)) %even number of columns
n = n/2;
else
if (length(sl) > length(sh))
n = floor(n/2);
else
n = ceil(n/2);
end %end inner if
end %end if - this finishes the columns
ms = [m ms];
ns = [n ns];
end %end for
%here we begin the synthesis process
for i=1:levs
sy = an(1:ms(i),1:ns(i)); %choose the appropriate part
sy = wsss1(sy,sl,sh); %one level of synthesis
an(1:ms(i),1:ns(i)) = sy; %put back the reconstruction
end %endfor
%plot the reconsructed array
figure;colormap(gray);imagesc(sy);title('IDWT of the Input DWT Array')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -