- %function wvlet=waveup2(x)
- function [ll,hl,lh,hh]=waveup2(x)
- x=double(x);
- wvlet=x;
- [hp,lp]=size(x);
- hc=hp/2;
- lc=lp/2;
- %奇偶列重排
- for n=1:lc
- j=n*2-1;
- wvlet(:,n)=x(:,j);
- wvlet(:,lc+n)=x(:,j+1);
- end
- %行变换开始
- for n=1:lc-1
- k=(wvlet(:,n)+wvlet(:,n+1))/2;
- wvlet(:,lc+n)=wvlet(:,lc+n)-k;
- end
- k=(wvlet(:,lc)+wvlet(:,lc-1))/2;
- wvlet(:,lp)=wvlet(:,lp)-k;
- k=(wvlet(:,lc+2)+wvlet(:,lc+1))/4;
- wvlet(:,1)=wvlet(:,1)+k;
- for n=2:lc
- k=(wvlet(:,lc+n)+wvlet(:,lc+n-1))/4;
- wvlet(:,n)=wvlet(:,n)+k;
- end
- %行变换结束
- x=wvlet;
- %奇偶行重排
- for n=1:hc
- j=n*2-1;
- wvlet(n,:)=x(j,:);
- wvlet(hc+n,:)=x(j+1,:);
- end
- %列重排开始
- for n=1:hc-1
- k=(wvlet(n,:)+wvlet(n+1,:))/2;
- wvlet(hc+n,:)=wvlet(hc+n,:)-k;
- end
- k=(wvlet(hc,:)+wvlet(hc-1,:))/2;
- wvlet(hp,:)=wvlet(hp,:)-k;
- k=(wvlet(hc+2,:)+wvlet(hc+1,:))/4;
- wvlet(1,:)=wvlet(1,:)+k;
- for n=2:hc
- k=(wvlet(hc+n,:)+wvlet(hc+n-1,:))/4;
- wvlet(n,:)=wvlet(n,:)+k;
- end
- %列重排结束
- %wvlet=uint8(wvlet);
- ll=wvlet(1:hc,1:lc);
- hl=wvlet(1:hc,lc+1:lp);
- lh=wvlet(hc+1:hp,1:lc);
- hh=wvlet(hc+1:hp,lc+1:lp);
复制代码 |