小波实验报告双树复小波变换Word文档格式.docx
- 文档编号:17873579
- 上传时间:2022-12-11
- 格式:DOCX
- 页数:25
- 大小:276.91KB
小波实验报告双树复小波变换Word文档格式.docx
《小波实验报告双树复小波变换Word文档格式.docx》由会员分享,可在线阅读,更多相关《小波实验报告双树复小波变换Word文档格式.docx(25页珍藏版)》请在冰豆网上搜索。
x=round((drawcirc(64,1,0,0,256)-*200);
setfig
(1);
colormap(gray(256))
image(min(max(x+128,1),256));
set(gca,'
position'
[.25.5]);
axis('
off'
);
image'
%draw(xx);
title('
Input(256x256)'
'
FontSize'
14);
drawnow
%Do4levelsofCWT.
[Yl,Yh]=dtwavexfm2(x,4,'
near_sym_b'
qshift_b'
%Looptoreconstructoutputfromcoefsateachlevelinturn.
%Startswiththefinestlevel.
titl=['
1st'
;
'
2nd'
3rd'
4th'
Low'
];
yy=zeros(size(x).*[23]);
yt1=1:
size(x,1);
yt2=1:
size(x,2);
formlev=1:
5,
mask=zeros(6,5);
mask(:
mlev)=1;
z=dtwaveifm2(Yl*mask(1,5),Yh,'
mask);
figure;
draw(z);
drawnow
yy(yt1,yt2)=z;
yt2=yt2+size(x,2)/2;
end
%disp('
Pressakey...'
)
%pause
%NowdosamewithDWT.
%Do4levelsofRealDWTusing'
antonini'
(9,7)-tapfilters.
[Yl,Yh]=wavexfm2(x,4,'
yt1=[1:
size(x,1)]+size(x,1);
mask=zeros(3,5);
z=waveifm2(Yl*mask(1,5),Yh,'
figure;
setfig(gcf);
image(min(max(yy+128,1),256));
[.8.8]);
holdon
plot(128*[[1;
1]*[1:
4][0;
6]]+1,128*[[0;
4]*[1111][2;
2]]+1,'
-k'
holdoff
Componentsofreconstructed'
disc'
images'
text*size(yy,2),*size(yy,1),'
DTCWT'
horiz'
r'
wavelets:
vert'
t'
DWT'
fork=1:
4,text(k*128-63,size(yy,1)*,sprintf('
level%d'
k),'
14,'
c'
end
text(5*128+1,size(yy,1)*,'
level4scalingfn.'
%print-deps
disp('
Pressakeytoseeperfectreconstructionproperty...'
pause
%Accumulatetheimagesfromlowbandupwardstoshowperfectreconstruction.
sy=size(x,2)/2;
formlev=4:
-1:
1,
yt2=[1:
sy]+(mlev-1)*sy;
yy(:
yt2)=yy(:
yt2)+yy(:
yt2+sy);
AccumulatedreconstructionsfromeachlevelofDTCWT'
text(size(yy,2)*,size(yy,1)*,'
AccumulatedreconstructionsfromeachlevelofDWT'
hor'
return
(2)functionp=drawcirc(r,w,dx,dy,N)
%functionp=drawcirc(r,w,dx,dy,N)
%GenerateanimageofsizeN*Npels,containingacircle
%radiusrpelsandcentredatdx,dyrelative
%tothecentreoftheimage.Theedgeofthecircleisacosineshaped
%edgeofwidthw(from10to90%points).
x=ones(N,1)*(([1:
N]-(N+1)/2-dx)/r);
y=(([1:
N]'
-(N+1)/2-dy)/r)*ones(1,N);
p=+*sin(min(max((exp*(x+y))-exp)*(r*3/w),-pi/2),pi/2));
(3)functionZ=dtwaveifm2(Yl,Yh,biort,qshift,gain_mask);
%Functiontoperformann-leveldual-treecomplexwavelet(DTCWT)
%2-Dreconstruction.
%Z=dtwaveifm2(Yl,Yh,biort,qshift,gain_mask);
%Yl->
Thereallowpassimagefromthefinallevel
%Yh->
Acellarraycontainingthe6complexhighpasssubimagesforeachlevel.
%biort->
'
=>
Antonini9,7tapfilters.
%'
legall'
LeGall5,3tapfilters.
near_sym_a'
Near-Symmetric5,7tapfilters.
Near-Symmetric13,19tapfilters.
%qshift->
qshift_06'
QuarterSampleShiftOrthogonal(Q-Shift)10,10tapfilters,
%(only6,6non-zerotaps).
qshift_a'
Q-shift10,10tapfilters,
%(with10,10non-zerotaps,unlikeqshift_06).
Q-Shift14,14tapfilters.
qshift_c'
Q-Shift16,16tapfilters.
qshift_d'
Q-Shift18,18tapfilters.
%gain_mask->
Gaintobeappliedtoeachsubband.
%gain_mask(d,l)isgainforsubbandwithdirectiondatlevell.
%Ifgain_mask(d,l)==0,nocomputationisperformedforband(d,l).
%Defaultgain_mask=ones(6,length(Yh)).
%Z->
Reconstructedrealimagematrix
%Forexample:
Z=dtwaveifm2(Yl,Yh,'
%performsa3-levelreconstructionfromYl,Yhusingthe13,19-tapfilters
%forlevel1andtheQ-shift14-tapfiltersforlevels>
=2.
%NickKingsburyandCianShaffrey
%CambridgeUniversity,May2002
a=length(Yh);
%Nooflevels.
ifnargin<
5,gain_mask=ones(6,a);
end%Defaultgain_mask.
ifisstr(biort)&
isstr(qshift)%Checkiftheinputsarestrings
biort_exist=exist([biort'
.mat'
]);
qshift_exist=exist([qshift'
ifbiort_exist==2&
qshift_exist==2;
%Checktoseeiftheinputsexistas.matfiles
load(biort);
load(qshift);
else
error('
PleaseenterthecorrectnamesoftheBiorthogonalorQ-ShiftFilters,seehelpDTWAVEIFM2fordetails.'
else
PleaseenterthenamesoftheBiorthogonalorQ-ShiftFiltersasshowninhelpDTWAVEIFM2.'
current_level=a;
Z=Yl;
whilecurrent_level>
=2;
;
%thisensuresthatforlevel-1weneverdothefollowing
lh=c2q(Yh{current_level}(:
:
[16]),gain_mask([16],current_level));
hl=c2q(Yh{current_level}(:
[34]),gain_mask([34],current_level));
hh=c2q(Yh{current_level}(:
[25]),gain_mask([25],current_level));
%DoevenQshiftfiltersoncolumns.
y1=colifilt(Z,g0b,g0a)+colifilt(lh,g1b,g1a);
y2=colifilt(hl,g0b,g0a)+colifilt(hh,g1b,g1a);
%DoevenQshiftfiltersonrows.
Z=(colifilt(y1.'
g0b,g0a)+colifilt(y2.'
g1b,g1a)).'
%ChecksizeofZandcropasrequired
[row_sizecol_size]=size(Z);
S=2*size(Yh{current_level-1});
ifrow_size~=S
(1)%checktoseeifthisresultneedstobecroppedfortherows
Z=Z(2:
row_size-1,:
end
ifcol_size~=S
(2)%checktoseeifthisresultneedstobecroppedforthecols
Z=Z(:
2:
col_size-1);
ifany(size(Z)~=S(1:
2)),
SizesofsubbandsarenotvalidforDTWAVEIFM2'
current_level=current_level-1;
ifcurrent_level==1;
%Dooddtop-levelfiltersoncolumns.
y1=colfilter(Z,g0o)+colfilter(lh,g1o);
y2=colfilter(hl,g0o)+colfilter(hh,g1o);
%Dooddtop-levelfiltersonrows.
Z=(colfilter(y1.'
g0o)+colfilter(y2.'
g1o)).'
%==========================================================================================
%**********INTERNALFUNCTION**********
functionx=c2q(w,gain)
%functionz=c2q(w,gain)
%Scalebygainandconvertfromcomplexw(:
1:
2)torealquad-numbersinz.
%Arrangepixelsfromtherealandimagpartsofthe2subbands
%into4separatesubimages.
%A----BReImofw(:
1)
%||
%C----DReImofw(:
2)
sw=size(w);
x=zeros(2*sw(1:
2));
ifany(w(:
))&
any(gain)
sc=sqrt*gain;
P=w(:
1)*sc
(1)+w(:
2)*sc
(2);
Q=w(:
1)*sc
(1)-w(:
t1=1:
2:
t2=1:
%Recovereachofthe4cornersofthequads.
x(t1,t2)=real(P);
%a=(A+C)*sc;
x(t1,t2+1)=imag(P);
%b=(B+D)*sc;
x(t1+1,t2)=imag(Q);
%c=(B-D)*sc;
x(t1+1,t2+1)=-real(Q);
%d=(C-A)*sc;
(3)function[Yl,Yh,Yscale]=dtwavexfm2(X,nlevels,biort,qshift);
%Functiontoperforman-levelDTCWT-2Ddecompostionona2DmatrixX
%[Yl,Yh,Yscale]=dtwavexfm2(X,nlevels,biort,qshift);
%X->
2Drealmatrix/Image
%nlevels->
No.oflevelsofwaveletdecomposition
%Yscale->
ThisisanOPTIONALoutputargument,thatisacellarraycontaining
%reallowpasscoefficientsforeveryscale.
%Example:
[Yl,Yh]=dtwavexfm2(X,3,'
%performsa3-leveltransformontherealimageXusingthe13,19-tapfilters
%CambridgeUniversity,Sept2001
%Checktoseeiftheinputsexistas.matfiles
PleaseenterthecorrectnamesoftheBiorthogonalorQ-ShiftFilters,seehelpDTWAVEXFM2fordetails.'
PleaseenterthenamesoftheBiorthogonalorQ-ShiftFiltersasshowninhelpDTWAVEXFM2.'
end
orginal_size=size(X);
ifndims(X)>
=3;
error(sprintf('
Theenteredimageis%dx%dx%d,pl
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 实验 报告 双树复小波 变换