Search code examples
mathimage-processingsignal-processinghaar-wavelet

Create NxN Haar Matrix


I can't find a definition for generating an un-normalized NxN Haar matrix. So what is the equation?

see: http://en.wikipedia.org/wiki/Haar_wavelet

Thx, Chris


Solution

  • Thx all. Wikipedia gives the 'equation':

    I've wrote a recursive solution for generating an un-normalized NxN Haar matrix in octave.

    function [h] = haar(n)
    h = [1];
    if n > 2
        h = haar(n/2);
    endif
    % calculate upper haar part
    h_n = kron(h,[1,1]); 
    % calculate lower haar part 
    h_i = kron(eye(length(h)),[1,-1]);
    % combine parts
    h = [h_n; h_i];
    endfunction
    
    disp(haar(8));