function A=invfasthaar2(A); % % first attempt of a FAST 2dim Haar wavelet transform % ovrwriting the original matrix % working from the finest level up, replace each % 2x2 block by average in top left, and differences % along horizontal, vertical, diagonal in other 3 % this is implemented by reshape and matrixmult % then recursively consider only top left entries % of each block, and do THE SAME operation to each % % eventually want to code the inverse similarily % and to display basis elements and lin comb's % as rastered images % quality measure is energy in each frequency % and in vertical / horizontal variation and % diagonal dominance % % first attempt August 2008 N=size(A,1); n=log(N)/log(2); image(32*(A+1)) pause T=[1 1 1 1;1 1 -1 -1;1 -1 1 -1;1 -1 -1 1]/2; for k=n-1:-1:0 for i=0:2^(k+1):N-2 for j=0:2^(k+1):N-2 M=[i+1:i+2,j+1:j+2]; A(i+1:2^k:i+2^k+1,j+1:2^k:j+2^k+1)=... reshape(T'*reshape(A(i+1:2^k:i+2^k+1,j+1:2^k:j+2^k+1),4,1),2,2); image(32*(A+1)) pause end end pause end A pause end