📄 hvanalysis.m
字号:
% % wavelet analysis of a image region% h0: analysis lowpass h1: analysis highpass% Ain: input image [M x N]% [sr, sc] and [er, ec] specify the rect region of Ain% to be decomposed. % diret:horizontal =1 vertical = -1; % A: output images, only the region is changed%% function [A]=hvanalysis(h0, h1, Ain, sr, sc, er, ec, diret)%function [A]=hvanalysis(Ain,sr,sc,er,ec,diret)h0=[0.037828, -0.023849, -0.110624, 0.377402, 0.852699, 0.377402, -0.110624, -0.023849, 0.037828] ;h1=[0.064539, -0.040689,-0.418092, 0.788486, -0.418092, -0.040689, 0.064539];RRM=(sr+er-1)/2;CCM=(sc+ec-1)/2;if ( diret >0),% disp(' horizontal analysis .....'); for rn=sr:er, lowpart=filterdown(h0, Ain(rn,sc:ec),0); highpart=filterdown(h1, Ain(rn, sc:ec),1); Ain(rn, sc:CCM)=lowpart; Ain(rn, (CCM+1):ec)=highpart; endelse% disp(' vertical analysis .....'); for cn=sc:ec, lowpart=filterdown(h0, Ain(sr:er, cn),0); highpart=filterdown(h1, Ain(sr:er, cn),1); Ain(sr:RRM, cn)=lowpart; Ain((RRM+1):er, cn)=highpart; endendA=Ain;%-------------filterdown-------------function y=filterdown(B, x, flag) yt=mfilter(B, x); N=length(yt); y=yt((1+flag):2:N);return;% ------------mfilter functionfunction [y]=mfilter(B, x)len=length(x);y=zeros(1, len);[RN CN]=size(x);if CN==1, x=x';endflen=length(B);xe=[ fliplr(x(2:len)), x, fliplr( x(1:(len-1)))];dd=(flen-1)/2;yt=filter(B,1, xe);y=yt( (len+dd):(len+len-1+dd));if CN==1, y=y';endreturn;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -