Академический Документы
Профессиональный Документы
Культура Документы
WaveletSoftwareatBrooklynPoly
MatlabImplementationofWaveletTransforms
ShihuaCai&KeyongLi
Advisor:Prof.IvanSelesnick
2DDiscreteWaveletTransform
1.2DFilterBanks
To use the wavelet transform for image processing we must
implement a 2D version of the analysis and synthesis filter
banks.Inthe2Dcase,the1Danalysisfilterbankisfirstapplied
tothecolumnsoftheimageandthenappliedtotherows.Ifthe
imagehasN1rowsandN2columns,thenafterapplyingthe1D
analysis filter bank to each column we have two subband
images, each having N1/2 rows and N2 columns afterapplying
the 1D analysis filter bank to each row of both of the two
subband images, we have four subband images, each having
N1/2 rows and N2/2 columns. This is illustrated in the diagram
below. The 2D synthesis filter bank combines the four subband
imagestoobtaintheoriginalimageofsizeN1byN2.
http://eeweb.poly.edu/iselesni/WaveletSoftware/standard2D.html
1/5
12/30/2015
WaveletSoftwareatBrooklynPoly
Table2.1Matlabfunctionafb2D.m
function[lo,hi]=afb2D(x,af1,af2)
%2DAnalysisFilterBank
%
%[lo,hi]=afb2D(x,af1,af2);
%INPUT:
%xNxMmatrix,wheremin(N,M)>2*length(filter)
%(N,Mareeven)
%af1analysisfilterforthecolumns
%af2analysisfilterfortherows
%afi(:,1)lowpassfilter
%afi(:,2)highpassfilter
%OUTPUT:
%lo,hilowpass,highpasssubbands
%hi{1}='lohi'subband
%hi{2}='hilo'subband
%hi{3}='hihi'subband
ifnargin<3
af2=af1;
end
%filteralongcolumns
[L,H]=afb2D_A(x,af1,1);
%filteralongrows
[lohi{1}]=afb2D_A(L,af2,2);
[hi{2}hi{3}]=afb2D_A(H,af2,2);
2/5
12/30/2015
WaveletSoftwareatBrooklynPoly
SeparableDWT
1DDWT
2DDWT
3DDWT
2.2DDiscreteWaveletTransform
Asinthe1Dcase,the2Ddiscretewavelettransformofasignal
DualtreeDWT
1DDWT
2DDWT
3DDWT
Denoising
Thresholding
BiShrink
References
People
Download(zip)
Table2.2Matlabfunctiondwt2D.m
functionw=dwt2D(x,J,af)
%discrete2Dwavelettransform
%
%w=dwt2D(x,stages,af)
%INPUT:
%x:NxMmatrix(N,Meven)
%J:numberofstages
%af:analysisfilters
%OUPUT:
%w:cellarrayofwaveletcoefficients
fork=1:J
[xw{k}]=afb2D(x,af,af);
end
w{J+1}=x;
Again,wisaMatlabcellarrayforj=1..J,d=1..3,w{j}{d}is
oneofthethreesubbandimagesproducedatstagej.w{J+1}is
the lowpass subband image produced at the last stage. The
functionidwt2D.mcomputestheinverse2DDWT.
3/5
12/30/2015
WaveletSoftwareatBrooklynPoly
>>[af,sf]=farras;
>>x=rand(128,64);
>>w=dwt2D(x,3,af);
>>y=idwt2D(w,3,sf);
>>err=xy;
>>max(max(abs(err)))
ans=
8.9817e014
Note that the first two wavelets are oriented in the vertical and
horizontaldirections,however,thethirdwaveletdoesnothavea
dominant orientation. The third wavelet mixes two diagonal
orientations, which gives rise to the checkerboard artifact. (The
2D DWT is poor at isolating the two diagonal orientations.) This
figure was produced with the following Matlab code fragment
(dwt2D_plots.m).
Table2.3Matlabfunctiondwt2D_plots.m
%dwt2D_plots
%DISPLAY2DWAVELETSOFDWT2D.M
[af,sf]=farras;
J=5;
L=3*2^(J+1);
N=L/2^J;
http://eeweb.poly.edu/iselesni/WaveletSoftware/standard2D.html
4/5
12/30/2015
WaveletSoftwareatBrooklynPoly
x=zeros(L,3*L);
w=dwt2D(x,J,af);
w{J}{1}(N/2,N/2+0*N)=1;
w{J}{2}(N/2,N/2+1*N)=1;
w{J}{3}(N/2,N/2+2*N)=1;
y=idwt2D(w,J,sf);
figure(1)
clf
imagesc(y);
axisequal
axisoff
colormap(gray(128))
Asinthe1Dcase,wesetallofthewaveletcoefficientstozero,
for the exception of one wavelet coefficient in each of the three
subbands.Wethentaketheinversewavelettransform.
Summaryofprograms:
1. farras.mAsetofperfectreconstructionfilters
2. afb2D.mAnalysisfilterbank(singlestage)
3. sfb2D.mSynthesisfilterbank(singlestage)
4. dwt2D.mForwardwavelettransform
5. idwt2D.mInversewavelettransform
6. cshift2D.mCircularshift
7. dwt2D_plots.mDisplay2dwaveletsofdwt2d.m
SupportedbygrantsfromtheNationalScienceFoundation andtheOthmerInstitutefor
InterdisciplinaryStudies
ElectricalEngineering,PolytechnicUniversity
6MetrotechCenter,Brooklyn,NY11201
http://eeweb.poly.edu/iselesni/WaveletSoftware/standard2D.html
5/5