📄 synthh2d.m
字号:
function sy = synthh2d(an,sl,sh,levs);
%Routine to reconstruct the multilevel DWT decomposed 2-D signal using
%even length or half sample symmetric (HSS) separable biorthogonal
%filter bank. Symmetric extension used to extend the subbands for
%synthesis. This corresponds to the analysis routine 'analh2d'.
%
%sy = synthh2d(an,lpf,hpf,L) reconstructs a 2-D array, from its DWT, an,
%which could be the output of the routine 'analh2d'.
%The image is assumed to be decomposed to L levels. The WSS filter
%bank used is comprised of sl and sh. If this corresponds to the
%analysis filter bank used for DWT, then you get perfect
%reconstruction. The reconstructed image is returned in 'sy'.
%
%sy = synthh2d(an,fopt,L) reconstructs a 2-D array, from its DWT an,
%which could be the output of the routine 'analh2d'.
%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 in '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, 2 or 3 and correspond to the 6/2, 2/6 and
% 4/4 tap HSS filter banks respectively.
%L : Number of levels of decomposition and hence synthesis.
%
%The reconstructed image returned in 'sy' can be plotted using the
%'image' or the 'imagesc' commands in conjunction with the 'colormap'
%command to specify the color map. Please refer to the online help
%for more information.
%
%The reconstructed image 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.17677669529664 0.17677669529664 0.70710678118655 0.70710678118655 0.17677669529664 -0.17677669529664];
sh =[-0.70710678118655 0.70710678118655];
elseif (sl ==2)
sl =[0.70710678118655 0.70710678118655];
sh =[-0.17677669529664 -0.17677669529664 0.70710678118655 -0.70710678118655 0.17677669529664 0.17677669529664];
elseif (sl >=3)
if (sl > 3)
fprintf('fopt chosen to be greater than 3. Using fopt= 3 instead\n');
end;
sl =[-0.35355339059327 1.06066017177982 1.06066017177982 -0.35355339059327];
sh =[-0.17677669529664 0.53033008588991 -0.53033008588991 0.17677669529664];
end %end inner if
end %enf if
[m,n] = size(an);
ms = [m]; %initialize
ns = [n]; %initialize
%compute the subband sizes
for i = 1:levs-1
if (length(sh)/4 == round(length(sh)/4))
if(m/2 == round(m/2))
m = m/2;
else
m = (m+1)/2;
end %end inner if
else
if (m/2 == round(m/2))
m = m/2 +1 ;
else
m = (m+1)/2;
end %end inner if
end % end if
if (length(sh)/4 == round(length(sh)/4))
if(n/2 == round(n/2))
n = n/2;
else
n = (n+1)/2;
end %end inner if
else
if (n/2 == round(n/2))
n = n/2 +1 ;
else
n = (n+1)/2;
end %end inner if
end % end if
ms = [m ms];
ns = [n ns];
end %end for
for i = 1:levs
sy = an(1:ms(i),1:ns(i)); %isolate the highest level
sy = hsss1(sy,sl,sh); %one level synthesis
an(1:ms(i),1:ns(i)) = sy;
end %endfor
%plot the reconstructed array
figure;colormap(gray);imagesc(sy);title('IDWT of Input DWT Array');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -