Wavelet-based image multiscale analysis of secret 2_matlab-wavelet analysis &matab implementation

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.