小波实验报告双树复小波变换.docx

上传人:b****5 文档编号:4920189 上传时间:2022-12-11 格式:DOCX 页数:25 大小:276.91KB
下载 相关 举报
小波实验报告双树复小波变换.docx_第1页
第1页 / 共25页
小波实验报告双树复小波变换.docx_第2页
第2页 / 共25页
小波实验报告双树复小波变换.docx_第3页
第3页 / 共25页
小波实验报告双树复小波变换.docx_第4页
第4页 / 共25页
小波实验报告双树复小波变换.docx_第5页
第5页 / 共25页
点击查看更多>>
下载资源
资源描述

小波实验报告双树复小波变换.docx

《小波实验报告双树复小波变换.docx》由会员分享,可在线阅读,更多相关《小波实验报告双树复小波变换.docx(25页珍藏版)》请在冰豆网上搜索。

小波实验报告双树复小波变换.docx

小波实验报告双树复小波变换

一、题目:

双树复小波变换

二、目的:

双树复小波和实小波变换的比较

三、算法及其实现:

提取阶梯型边界点

1.

算法。

幅值:

相位:

2.代码实现。

我采用Matlab函数编程实现。

具体程序见,,,,,,

设和分别是双正交对偶尺度函数与对偶小波,,,和是相应的低通滤波器和高通滤波器,即它们满足

实部:

虚部:

 

双树复小波变换可以通过离散小波变换DWT实现:

一个DWT产生实部,另一个产生虚部。

4、实现工具:

Matlab

5、程序代码:

(1):

%

%

%M-filetoperforma4-levelwavelettransformonacircleusingQ-shift

%dualwavelettreeandDWT,andtocompareshiftinvarianceproperties.

%

%NickKingsbury,CambridgeUniversity,May2002.

clearall

closeall

%Drawacirculardisc.

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');

axis('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,'near_sym_b','qshift_b',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,'antonini');

yt1=[1:

size(x,1)]+size(x,1);yt2=1:

size(x,2);

formlev=1:

5,

mask=zeros(3,5);

mask(:

mlev)=1;

z=waveifm2(Yl*mask(1,5),Yh,'antonini',mask);

figure;draw(z);drawnow

yy(yt1,yt2)=z;

yt2=yt2+size(x,2)/2;

end

figure;

setfig(gcf);

colormap(gray(256))

image(min(max(yy+128,1),256));

set(gca,'position',[.8.8]);

axis('off');

axis('image');

holdon

plot(128*[[1;1]*[1:

4][0;6]]+1,128*[[0;4]*[1111][2;2]]+1,'-k');

holdoff

title('Componentsofreconstructed''disc''images','FontSize',14);

text*size(yy,2),*size(yy,1),'DTCWT','horiz','r');

text*size(yy,2),*size(yy,1),'wavelets:

','horiz','r','vert','t');

text*size(yy,2),*size(yy,1),'DWT','horiz','r');

fork=1:

4,text(k*128-63,size(yy,1)*,sprintf('level%d',k),'FontSize',14,'horiz','c','vert','t');end

text(5*128+1,size(yy,1)*,'level4scalingfn.','FontSize',14,'horiz','c','vert','t');

drawnow

%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);

end

figure;

setfig(gcf);

colormap(gray(256))

image(min(max(yy+128,1),256));

set(gca,'position',[.8.8]);

axis('off');

axis('image');

title('AccumulatedreconstructionsfromeachlevelofDTCWT','FontSize',14);

text(size(yy,2)*,size(yy,1)*,'AccumulatedreconstructionsfromeachlevelofDWT','FontSize',14,'hor','c','vert','t');

drawnow

 

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));

return

(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->'antonini'=>Antonini9,7tapfilters.

%'legall'=>LeGall5,3tapfilters.

%'near_sym_a'=>Near-Symmetric5,7tapfilters.

%'near_sym_b'=>Near-Symmetric13,19tapfilters.

%

%qshift->'qshift_06'=>QuarterSampleShiftOrthogonal(Q-Shift)10,10tapfilters,

%(only6,6non-zerotaps).

%'qshift_a'=>Q-shift10,10tapfilters,

%(with10,10non-zerotaps,unlikeqshift_06).

%'qshift_b'=>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,'near_sym_b','qshift_b');

%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'.mat']);

ifbiort_exist==2&qshift_exist==2;%Checktoseeiftheinputsexistas.matfiles

load(biort);

load(qshift);

else

error('PleaseenterthecorrectnamesoftheBiorthogonalorQ-ShiftFilters,seehelpDTWAVEIFM2fordetails.');

end

else

error('PleaseenterthenamesoftheBiorthogonalorQ-ShiftFiltersasshowninhelpDTWAVEIFM2.');

end

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);

end

ifany(size(Z)~=S(1:

2)),

error('SizesofsubbandsarenotvalidforDTWAVEIFM2');

end

current_level=current_level-1;

end

ifcurrent_level==1;

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));

%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)).';

end

return

%==========================================================================================

%**********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(:

:

2)*sc

(2);

t1=1:

2:

size(x,1);

t2=1:

2:

size(x,2);

%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;

end

return

(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

%

%biort->'antonini'=>Antonini9,7tapfilters.

%'legall'=>LeGall5,3tapfilters.

%'near_sym_a'=>Near-Symmetric5,7tapfilters.

%'near_sym_b'=>Near-Symmetric13,19tapfilters.

%

%qshift->'qshift_06'=>QuarterSampleShiftOrthogonal(Q-Shift)10,10tapfilters,

%(only6,6non-zerotaps).

%'qshift_a'=>Q-shift10,10tapfilters,

%(with10,10non-zerotaps,unlikeqshift_06).

%'qshift_b'=>Q-Shift14,14tapfilters.

%'qshift_c'=>Q-Shift16,16tapfilters.

%'qshift_d'=>Q-Shift18,18tapfilters.

%

%

%Yl->Thereallowpassimagefromthefinallevel

%Yh->Acellarraycontainingthe6complexhighpasssubimagesforeachlevel.

%Yscale->ThisisanOPTIONALoutputargument,thatisacellarraycontaining

%reallowpasscoefficientsforeveryscale.

%

%

%Example:

[Yl,Yh]=dtwavexfm2(X,3,'near_sym_b','qshift_b');

%performsa3-leveltransformontherealimageXusingthe13,19-tapfilters

%forlevel1andtheQ-shift14-tapfiltersforlevels>=2.

%

%NickKingsburyandCianShaffrey

%CambridgeUniversity,Sept2001

ifisstr(biort)&isstr(qshift)%Checkiftheinputsarestrings

biort_exist=exist([biort'.mat']);

qshift_exist=exist([qshift'.mat']);

ifbiort_exist==2&qshift_exist==2;%Checktoseeiftheinputsexistas.matfiles

load(biort);

load(qshift);

else

error('PleaseenterthecorrectnamesoftheBiorthogonalorQ-ShiftFilters,seehelpDTWAVEXFM2fordetails.');

end

else

error('PleaseenterthenamesoftheBiorthogonalorQ-ShiftFiltersasshowninhelpDTWAVEXFM2.');

end

orginal_size=size(X);

ifndims(X)>=3;

error(sprintf('Theenteredimageis%dx%dx%d,pl

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 数学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1