1.MATLAB program Writing Step 1, the wavelet W (t) and the original function f (t) are compared to the beginning of the calculation coefficient c. The coefficient c indicates the similarity between the partial function and the wavelet.
2. Move the wavelet to the right K unit, get the wavelet w (t-k), repeat 1. Repeat the section to know that the function f ends.
3. Extend the wavelet W (t), get the wavelet W (T/2) and repeat the step 1,2.
4. Continuously expand the wavelet, repeat 1,2,3.
The Haar wavelets used here, the scaling function is [1 1], the wavelet function is [1-1], is the simplest small wave.
2.MATLAB Source Code and analysis
Clear All;close ALL;CLC;
Img=double (Imread (' ziheng.jpg '));
[M,n]=size (IMG);
[Ll,lh,hl,hh]=haar_dwt2d (IMG); %dwt2 (IMG, ' Haar ') like
img=[ll LH; HL HH]; % one layer decomposition
imgn=zeros (m,n);
For I=0:M/2:M/2 for
J=0:N/2:N/2
[Ll,lh,hl,hh]=haar_dwt2d (I+1:I+M/2,J+1:J+N/2);% to decompose four images after one layer decomposition
IMGN (I+1:I+M/2,J+1:J+N/2) =[ll LH; HL HH];
End
End
Imshow (IMGN)
function [Ll,lh,hl,hh]=haar_dwt2d (IMG)
[M,n]=size (IMG);
For i=1:m % each row is decomposed
[L,H]=HAAR_DWT (IMG (i,:));
IMG (i,:) =[l H];
End -for j=1:n% each column is decomposed
[L,h]=haar_dwt (IMG (:, j));
IMG (:, j) =[l H];
End
% should not be added Mat2gray, but in order to have a good display effect on the addition of
Ll=mat2gray (IMG (1:M/2,1:N/2)); % of the ranks are low-frequency
lh=mat2gray (img (1:m/2,n/2+1:n)); % line Low frequency column high-frequency
hl=mat2gray (img (M/2+1:M,1:N/2)); % line High frequency column low-frequency
hh=mat2gray (img (m/2+1:m,n/2+1:n)); % of the ranks are high-frequency end
%HAAR_DWT.M
function [L,H]=HAAR_DWT (f)
% does not do boundary processing, the picture preferably is 2^n*2^n type
n=length (f);
N=N/2;
L=zeros (1,n); % low-frequency Component
H=zeros (1,n); % high frequency component for
i=1:n
L (i) = (f (2*i-1) +f (2*i))/sqrt (2);
H (i) = (f (2*i-1)-F (2*i))/sqrt (2);
End
3. Analysis of experimental results