版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、h(t)jg(t).f, - f h; j:f, g;dh(j,n)2dg(j,n)2,dg(j, n) arctan -dh(j, n)2.代码实现。我采用 Matlabdtwavexfm2.m,shift_test_2D.m, drawcirc.m,dtwaveifm2.m,waveifm2.m,wavexfm2.m函数编程实现。具体程序见setfig.m,SkelMap.m。设 h 和h% n实部:ho nh(t)2nhc(n) h(2tn)虚部:g(t)ngo(n) g(2tn)h(t).2nhi(n) h(2tn)g(t)3ngdn) g(2tn)洽t)2nh%(n) %(2tn)%
2、(t)2n%(n )%(2tn)%(t)2%(n) %(2tn)%(t).2粼)%(2tn)h 5n实现:一个DWT双树复小波变换可以通过离散小波变换 产生虚部。,%和 h, % 分别是双正交对偶尺度函数与对偶小波, 是相应的低通滤波器和高通滤波器,即它们满足nDWT产生实部,另一个一、题目:双树复小波变换二、目的:双树复小波和实小波变换的比较三、算法及其实现: 提取阶梯型边界点1.算法。c(t) 幅值:|dc(j,n) | 相位:dc( j, n)四、实现工具:Matlab五、程序代码:(1) shift_test_2D.m :% shift_test_2D.m% M-file to per
3、form a 4-level wavelet transform on a circle using Q-shift% dual wavelet tree and DWT, and to compare shift in varia nee properties.% Nick Ki ngsbury, Cambridge Un iversity. May 2002.clear all close all% Draw a circular disc.x = round(drawcirc(64,1,0,0,256) - 0.5) * 200); setfig(1);colormap(gray(256
4、)image(mi n(max(x+128,1),256);set(gca,'positio n',0.1 0.25 .25 .5);axis('off');axis('image');% draw(xx);title('Input (256 x 256)','FontSize',14); drawnow% Do 4 levels of CWT.Yl,Yh = dtwavexfm2(x,4,'near_sym_b','qshift_b');% Loop to reconstruct
5、output from coefs at each level in turn.% Starts with the finest level.titl = '1st''2nd''3rd''4th''Low'yy = zeros(size(x) .* 2 3);yt1 = 1:size(x,1); yt2 = 1:size(x,2);for mlev = 1:5,mask = zeros(6,5);mask(:,mlev) = 1;z = dtwaveifm2(Yl*mask(1,5),Yh,'near_sy
6、m_b','qshift_b',mask); figure;draw(z);drawnowyy(yt1,yt2) = z;yt2 = yt2 + size(x,2)/2;end% disp('Press a key .')% pause% Now do same with DWT.% Do 4 levels of Real DWT using 'antonini' (9,7)-tap filters.Yl,Yh = wavexfm2(x,4,'antonini');yt1 = 1:size(x,1) + size(x,1)
7、; yt2 = 1:size(x,2);for mlev = 1:5,mask = zeros(3,5);mask(:,mlev) = 1;z = waveifm2(Yl*mask(1,5),Yh,'antonini',mask);figure;draw(z);drawnowyy(yt1,yt2) = z;yt2 = yt2 + size(x,2)/2;endfigure;setfig(gcf); colormap(gray(256) image(min(max(yy+128,1),256);set(gca,'position',0.1 0.1 .8 .8);a
8、xis('off');axis('image');hold on plot(128*1;1*1:4 0;6+1,128*0;4*1 1 1 1 2;2+1,'-k'); hold offtitle('Components of reconstructed ''disc'' images','FontSize',14); text(-0.01*size(yy,2),0.25*size(yy,1),'DT CWT','horiz','r')
9、; text(0.02*size(yy,2),1.02*size(yy,1),'wavelets:','horiz','r','vert','t'); text(-0.01*size(yy,2),0.75*size(yy,1),'DWT','horiz','r');endfor k=1:4, text(k*128-63,size(yy,1)*1.02,sprintf('level %d',k),'FontSize',14,'ho
10、riz','c','vert','t');text(5*128+1,size(yy,1)*1.02,'level 4 scaling fn.','FontSize',14,'horiz','c','vert','t'); drawnow% print -deps circrecq.epsdisp('Press a key to see perfect reconstruction property .') pause% Accu
11、mulate the images from lowband upwards to show perfect reconstruction. sy = size(x,2)/2;for mlev = 4:-1:1,yt2 = 1:sy + (mlev-1)*sy;yy(:,yt2) = yy(:,yt2) + yy(:,yt2+sy);endfigure;setfig(gcf); colormap(gray(256) image(min(max(yy+128,1),256);set(gca,'position',0.1 0.1 .8 .8); axis('off'
12、);axis('image');title('Accumulated reconstructions from each level of DT CWT ','FontSize',14); text(size(yy,2)*0.5,size(yy,1)*1.02,'Accumulated reconstructions from each level of DWT ','FontSize',14,'hor','c','vert','t');drawnow
13、return(2) function p = drawcirc(r,w,dx,dy,N)% function p = drawcirc(r,w,dx,dy,N)% Generate an image of size N*N pels, containing a circle% radius r pels and centred at dx,dy relative% to the centre of the image. The edge of the circle is a cosine shaped% edge of width w (from 10 to 90% points).x = o
14、nes(N,1) * (1:N - (N+1)/2 - dx)/r); y = (1:N' - (N+1)/2 - dy)/r) * ones(1,N);p = 0.5 + 0.5 * sin(min(max(exp(-0.5 * (x+ y ) - exp(-0.5)*(r*3/w), -pi/2), pi/2);return(3) function Z = dtwaveifm2(Yl,Yh,biort,qshift,gain_mask);% Function to perform an n-level dual-tree complex wavelet (DTCWT)% 2-D r
15、econstruction.% Z = dtwaveifm2(Yl,Yh,biort,qshift,gain_mask);%Yl -> The real lowpass image from the final level%Yh -> A cell array containing the 6 complex highpass subimages for each level.% biort -> 'antonini' => Antonini 9,7 tap filters.% 'legall'=> LeGall 5,3 tap f
16、ilters.%'near_sym_a' => Near-Symmetric 5,7 tap filters.%'near_sym_b' => Near-Symmetric 13,19 tap filters.%qshift -> 'qshift_06' => Quarter Sample Shift Orthogonal (Q-Shift) 10,10 tap filters,(only 6,6 non-zero taps).'qshift_a' => Q-shift 10,10 tap filte
17、rs,(with 10,10 non-zero taps, unlike qshift_06).'qshift_b' => Q-Shift 14,14 tap filters. 'qshift_c' => Q-Shift 16,16 tap filters. 'qshift_d' => Q-Shift 18,18 tap filters. gain_mask -> Gain to be applied to each subband.gain_mask(d,l) is gain for subband with direc
18、tion d at level l.If gain_mask(d,l) = 0, no computation is performed for band (d,l). Default gain_mask = ones(6,length(Yh).%Z -> Reconstructed real image matrix% For example: Z = dtwaveifm2(Yl,Yh,'near_sym_b','qshift_b');% performs a 3-level reconstruction from Yl,Yh using the 13,
19、19-tap filters% for level 1 and the Q-shift 14-tap filters for levels >= 2.% Nick Kingsbury and Cian Shaffrey% Cambridge University, May 2002a = length(Yh); % No of levels.if nargin < 5, gain_mask = ones(6,a); end % Default gain_mask.if isstr(biort) & isstr(qshift)%Check if the inputs are
20、stringsbiort_exist = exist(biort '.mat');qshift_exist = exist(qshift '.mat');if biort_exist = 2 & qshift_exist = 2;%Check to see if the inputs exist as .mat filesload (biort);load (qshift);elseerror('Please enter the correct names of the Biorthogonal or Q-Shift Filters, see h
21、elp DTW AVEIFM2 for details.');end elseerror('Please enter the names of the Biorthogonal or Q-Shift Filters as shown in help DTW AVEIFM2.');endcurrent_level = a; Z = Yl;while current_level >= 2; ; %this ensures that for level -1 we never do the following lh = c2q(Yhcurrent_level(:,:,1
22、 6),gain_mask(1 6,current_level); hl = c2q(Yhcurrent_level(:,:,3 4),gain_mask(3 4,current_level); hh = c2q(Yhcurrent_level(:,:,2 5),gain_mask(2 5,current_level);% Do even Qshift filters on columns.y1 = colifilt(Z,g0b,g0a) + colifilt(lh,g1b,g1a);y2 = colifilt(hl,g0b,g0a) + colifilt(hh,g1b,g1a);% Do e
23、ven Qshift filters on rows.Z = (colifilt(y1.',g0b,g0a) + colifilt(y2.',g1b,g1a).'% Check size of Z and crop as requiredrow_size col_size = size(Z);S = 2*size(Yhcurrent_level-1);if row_size = S(1)%check to see if this result needs to be cropped for the rowsZ = Z(2:row_size-1,:);endif col_
24、size = S(2)%check to see if this result needs to be cropped for the colsZ = Z(:,2:col_size-1);endif any(size(Z) = S(1:2), error('Sizes of subbands are not valid for DTW AVEIFM2');endcurrent_level = current_level - 1;endif current_level = 1;lh = c2q(Yhcurrent_level(:,:,1 6),gain_mask(1 6,curr
25、ent_level);hl = c2q(Yhcurrent_level(:,:,3 4),gain_mask(3 4,current_level);hh = c2q(Yhcurrent_level(:,:,2 5),gain_mask(2 5,current_level);% Do odd top-level filters on columns.y1 = colfilter(Z,g0o) + colfilter(lh,g1o);y2 = colfilter(hl,g0o) + colfilter(hh,g1o);% Do odd top-level filters on rows.Z = (
26、colfilter(y1.',g0o) + colfilter(y2.',g1o).'endreturn*INTERNAL FUNCTION*function x = c2q(w,gain)% function z = c2q(w,gain)% Scale by gain and convert from complex w(:,:,1:2) to real quad-numbers in z. % Arrange pixels from the real and imag parts of the 2 subbands% into 4 separate subimag
27、es .%ABReIm of w(:,:,1)%| |%| |%CDReIm of w(:,:,2)sw = size(w);x = zeros(2*sw(1:2);if any(w(:) & any(gain)sc = sqrt(0.5) * 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);% Recover each of the 4 corners of the quads. x(t1,t2) = r
28、eal(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);% Function to perform a n-level DTCWT-2D decompostion on a 2D matrix X % Yl,Yh,Yscale =
29、dtwavexfm2(X,nlevels,biort,qshift);%X -> 2D real matrix/Image% nlevels -> No. of levels of wavelet decomposition%biort -> 'antonini' => Antonini 9,7 tap filters.% 'legall'=> LeGall 5,3 tap filters.%'near_sym_a' => Near-Symmetric 5,7 tap filters.%'near_sy
30、m_b' => Near-Symmetric 13,19 tap filters.%qshift -> 'qshift_06' => Quarter Sample Shift Orthogonal (Q-Shift) 10,10 tap filters,% (only 6,6 non-zero taps).% 'qshift_a' => Q-shift 10,10 tap filters,%(with 10,10 non-zero taps, unlike qshift_06).% 'qshift_b' =>
31、 Q-Shift 14,14 tap filters.%'qshift_c' => Q-Shift 16,16 tap filters.% 'qshift_d' => Q-Shift 18,18 tap filters. %Yl-> The real lowpass image from the final level%Yh-> A cell array containing the 6 complex highpass subimages for each level.%Yscale -> This is an OPTIONAL
32、output argument, that is a cell array containing%real lowpass coefficients for every scale.% Example: Yl,Yh = dtwavexfm2(X,3,'near_sym_b','qshift_b');% performs a 3-level transform on the real image X using the 13,19-tap filters% for level 1 and the Q-shift 14-tap filters for levels
33、>= 2.% Nick Kingsbury and Cian Shaffrey % Cambridge University, Sept 2001if isstr(biort) & isstr(qshift)%Check if the inputs are stringsbiort_exist = exist(biort '.mat');qshift_exist = exist(qshift '.mat');if biort_exist = 2 & qshift_exist = 2;%Check to see if the inputs e
34、xistas .mat filesload (biort);load (qshift);else error('Please enter the correct names of the Biorthogonal or Q-Shift Filters, see help DTW AVEXFM2 for details.');end elseerror('Please enter the names of the Biorthogonal or Q-Shift Filters as shown in help DTW AVEXFM2.');end orginal_
35、size = size(X);if ndims(X) >= 3;error(sprintf('The entered image is %dx%dx%d, please enter each image sliceseparately.',orginal_size(1),orginal_size(2),orginal_size(3); end% The next few lines of code check to see if the image is odd in size, if so an extra .% row/column will be added to
36、the bottom/right of the image initial_row_extend = 0; %initialise initial_col_extend = 0;if any(rem(orginal_size(1),2), %if sx(1) is not divisable by 2 then we need to extend X by adding a row at the bottomX = X; X(end,:); initial_row_extend = 1; end if any(rem(orginal_size(2),2), adding a col to th
37、e leftX = X X(:,end); initial_col_extend = 1; end extended_size = size(X);%Any further extension will be done in due course.%if sx(2) is not divisable by 2 then we need to extend X by%Any further extension will be done in due course.if nlevels = 0, return; end%initialiseYh=cell(nlevels,1);if nargout
38、 = 3Yscale=cell(nlevels,1); component.end%this is only required if the user specifies a third outputS = ; sx = size(X); if nlevels >= 1,% Do odd top-level filters on cols.Lo = colfilter(X,h0o).'Hi = colfilter(X,h1o).'% Do odd top-level filters on rows.LoLo = colfilter(Lo,h0o).'Yh1 = z
39、eros(size(LoLo)/26);Yh1(:,:,1 6) = q2c(colfilter(Hi,h0o).');% LoLo% Horizontal pairYh1(:,:,3 4) = q2c(colfilter(Lo,h1o).');Yh1(:,:,2 5) = q2c(colfilter(Hi,h1o).'); S = size(LoLo) ;S;% Vertical pair% Diagonal pairif nargout = 3Yscale1 = LoLo;end endif nlevels >= 2;for level = 2:nlevels
40、;row_size col_size = size(LoLo);if any(rem(row_size,4),% Extend by 2 rows if no. of rows of LoLo are divisableby 4;LoLo = LoLo(1,:); LoLo; LoLo(end,:);endif any(rem(col_size,4),% Extend by 2 cols if no. of cols of LoLo are divisable by4;LoLo = LoLo(:,1) LoLo LoLo(:,end);end% Do even Qshift filters o
41、n rows.Lo = coldfilt(LoLo,h0b,h0a).'Hi = coldfilt(LoLo,h1b,h1a).'% Do even Qshift filters on columns.LoLo = coldfilt(Lo,h0b,h0a).' %LoLoYhlevel = zeros(size(LoLo)/26);Yhlevel(:,:,1 6) = q2c(coldfilt(Hi,h0b,h0a).'); % HorizontalYhlevel(:,:,3 4) = q2c(coldfilt(Lo,h1b,h1a).'); % Ver
42、ticalYhlevel(:,:,2 5) = q2c(coldfilt(Hi,h1b,h1a).'); % DiagonalS = size(LoLo) ;S;if nargout = 3 Yscalelevel = LoLo;endend endYl = LoLo;if initial_row_extend = 1 & initial_col_extend = 1;warning(sprintf(' rr The image entered is now a %dx%d NOT a %dx%d r The bottom row and rightmost colum
43、n have been duplicated, prior to decomposition. rr ',.extended_size(1),extended_size(2),orginal_size(1),orginal_size(2); endif initial_row_extend = 1 ;warning(sprintf(' rr The image entered is now a %dx%d NOT a %dx%d r Row number %d has been duplicated, and added to the bottom of the image,
44、prior to decomposition. rr',.extended_size(1),extended_size(2),orginal_size(1),orginal_size(2),orginal_size(1);end if initial_col_extend = 1;warning(sprintf(' rr The image entered is now a %dx%d NOT a %dx%d r Col number %d has been duplicated, and added to the right of the image, prior to de
45、composition. rr',. extended_size(1),extended_size(2),orginal_size(1),orginal_size(2),orginal_size(2); end return function z = q2c(y)*INTERNAL FUNCTION*% function z = q2c(y)% Convert from quads in y to complex numbers in z.sy = size(y);t1 = 1:2:sy(1); t2 = 1:2:sy(2);j2 = sqrt(0.5 -0.5);% Arrange
46、pixels from the corners of the quads into% 2 subimages of alternate real and imag pixels. % ab% |% |% cd % Combine (a,b) and (d,c) to form two complex subimages.p = y(t1,t2)*j2(1) + y(t1,t2+1)*j2(2);% p = (a + jb) / sqrt(2)q = y(t1+1,t2+1)*j2(1) - y(t1+1,t2)*j2(2); % q = (d - jc) / sqrt(2)% Form the
47、 2 subbands in z.z = cat(3,p-q,p+q);return(4) function Z = dtwaveifm2(Yl,Yh,biort,qshift,gain_mask);% Function to perform an n-level dual-tree complex wavelet (DTCWT)% 2-D reconstruction.% Z = dtwaveifm2(Yl,Yh,biort,qshift,gain_mask);%Yl -> The real lowpass image from the final level%Yh -> A c
48、ell array containing the 6 complex highpass subimages for each level.%biort -> 'antonini' => Antonini 9,7 tap filters.% 'legall'=> LeGall 5,3 tap filters.%'near_sym_a' => Near-Symmetric 5,7 tap filters.%'near_sym_b' => Near-Symmetric 13,19 tap filters.%
49、qshift -> 'qshift_06' => Quarter Sample Shift Orthogonal (Q-Shift) 10,10 tap filters,%(only 6,6 non-zero taps).% 'qshift_a' => Q-shift 10,10 tap filters,%(with 10,10 non-zero taps, unlike qshift_06).% 'qshift_b' => Q-Shift 14,14 tap filters.% 'qshift_c' =&
50、gt; Q-Shift 16,16 tap filters.% 'qshift_d' => Q-Shift 18,18 tap filters.%gain_mask -> Gain to be applied to each subband.%gain_mask(d,l) is gain for subband with direction d at level l.%If gain_mask(d,l) = 0, no computation is performed for band (d,l).% Default gain_mask = ones(6,lengt
51、h(Yh).% Z -> Reconstructed real image matrix% % For example: Z = dtwaveifm2(Yl,Yh,'near_sym_b','qshift_b');% performs a 3-level reconstruction from Yl,Yh using the 13,19-tap filters % for level 1 and the Q-shift 14-tap filters for levels >= 2.% % Nick Kingsbury and Cian Shaffre
52、y % Cambridge University, May 2002 a = length(Yh); % No of levels.if nargin < 5, gain_mask = ones(6,a); end % Default gain_mask.if isstr(biort) & isstr(qshift)%Check if the inputs are stringsbiort_exist = exist(biort '.mat');qshift_exist = exist(qshift '.mat');if biort_exist =
53、 2 & qshift_exist = 2;%Check to see if the inputs exist as .mat filesload (biort);load (qshift);elseerror('Please enter the correct names of the Biorthogonal or Q-Shift Filters, see help DTW AVEIFM2 for details.');end elseerror('Please enter the names of the Biorthogonal or Q-Shift F
54、ilters as shown in help DTW AVEIFM2.');endcurrent_level = a; Z = Yl;while current_level >= 2; ; %this ensures that for level -1 we never do the following lh = c2q(Yhcurrent_level(:,:,1 6),gain_mask(1 6,current_level); hl = c2q(Yhcurrent_level(:,:,3 4),gain_mask(3 4,current_level); hh = c2q(Yh
55、current_level(:,:,2 5),gain_mask(2 5,current_level);% Do even Qshift filters on columns. y1 = colifilt(Z,g0b,g0a) + colifilt(lh,g1b,g1a);y2 = colifilt(hl,g0b,g0a) + colifilt(hh,g1b,g1a);% Do even Qshift filters on rows.Z = (colifilt(y1.',g0b,g0a) + colifilt(y2.',g1b,g1a).'% Check size of
56、 Z and crop as required row_size col_size = size(Z);S = 2*size(Yhcurrent_level-1);if row_size = S(1)%check to see if this result needs to be cropped for the rowsZ = Z(2:row_size-1,:);endif col_size = S(2)%check to see if this result needs to be cropped for the colsZ = Z(:,2:col_size-1);endif any(siz
57、e(Z) = S(1:2),error('Sizes of subbands are not valid for DTW AVEIFM2'); endcurrent_level = current_level - 1; endif current_level = 1;lh = c2q(Yhcurrent_level(:,:,1 6),gain_mask(1 6,current_level);hl = c2q(Yhcurrent_level(:,:,3 4),gain_mask(3 4,current_level);hh = c2q(Yhcurrent_level(:,:,2 5
58、),gain_mask(2 5,current_level);% Do odd top-level filters on columns. y1 = colfilter(Z,g0o) + colfilter(lh,g1o); y2 = colfilter(hl,g0o) + colfilter(hh,g1o);% Do odd top-level filters on rows.Z = (colfilter(y1.',g0o) + colfilter(y2.',g1o).'endreturn function x = c2q(w,gain)*INTERNAL FUNCTION*% function z = c2q(w,gain)% Scale by gain and convert from complex w(:,:,1:2) to real quad-numbers in z. % Arrange pixels from the real and imag parts of the 2 subbands% into 4 separate subimages .%ABReIm of w(:,:,1)%| |%| |%CDReIm of
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024年企业云服务合作协议
- 2024年城市护坡工程承包协议
- 2024年临时仓储场地租赁合同
- 2024年小型电力工程承包合同
- 劳动合同授权通知
- 2024年临时安保人员雇佣合同
- 2024年型号车辆买卖合同样本
- 2024年家具城批发购销合同
- 2024年宠物托管运输服务协议
- 积分兑换协议文件模板
- 生涯规划展示
- 洗涤厂规章制度
- 《武术基本简述》课件
- 互联网+农业智慧农业商业计划书
- 题材05乡土小说专题精练-2024年高考语文二轮复习三点突破讲解专练原卷版
- 中药在临床中的应用
- 《征兵入伍应征公民体格检查标准条文释义》
- 小学音乐新课程标准
- 小学生冬季安全教育知识讲座
- 工程数量控制办法
- 【公司盈利能力分析国内外文献综述2500字】
评论
0/150
提交评论