Haar Wavelet..

Hey, I have to basically input a 128*128 Haar Wavelet Matrix. Thing is, I'll either have to code it in or hardcode the values myself. Does anyone know any inbuilt class or any function I can use to save any time????

Answers (2)

Wayne King
Wayne King on 25 Aug 2011

0 votes

Hi Aditya, Can you be more specific what you mean by the Haar wavelet matrix? Are you attempting to implement a 1-D DWT using the Haar wavelet? And if so, is it necessary that you implement as a matrix multiplication. If you have the Wavelet Toolbox, there are much more efficients ways to do it.
Wayne

1 Comment

Aditya
Aditya on 25 Aug 2011
Hey! Thanks for your quick reply. I want a 2-D Haar Matrix...
like... 1 1 1 1
1 1 -1 -1
1 -1 0 0
0 0 1 -1
only well, for 128 rows and columns. I will then carry out the squaring of elements and division. Is there any inbuilt function or code which foes all this? Or will I have to do it on my own?

Sign in to comment.

mukala gayatri
mukala gayatri on 23 Sep 2020

0 votes

function H=haarmtx(n)
% HAARMTX Compute Haar orthogonal transform matrix.
%
% H = HAARMTX(N) returns the N-by-N HAAR transform matrix. H*A
% is the HAAR transformation of the columns of A and H'*A is the inverse
% transformation of the columns of A (when A is N-by-N).
% If A is square, the two-dimensional Haar transformation of A can be computed
% as H*A*H'. This computation is sometimes faster than using
% DCT2, especially if you are computing large number of small
% Haar transformation, because H needs to be determined only once.
%% Class Support
% -------------
% N is an integer scalar of class double. H is returned
% as a matrix of class double.
%
%
% I/O Spec
% N - input must be double
% D - output DCT transform matrix is double
%
% Author : Frederic Chanal (f.j.chanal@student.tue.nl) - 2004
a=1/sqrt(n);
for i=1:n
H(1,i)=a;
end
for k=1:n-1
p=fix(log2(k));
q=k-2^p+1;
t1=n/2^p;
sup=fix(q*t1);
mid=fix(sup-t1/2);
inft=fix(sup-t1);
t2=2^(p/2)*a;
for j=1:inft
H(k+1,j)=0;
end
for j=inft+1:mid
H(k+1,j)=t2;
end
for j=mid+1:sup
H(k+1,j)=-t2;
end
for j=sup+1:n
H(k+1,j)=0;
end
end

Categories

Find more on Discrete Multiresolution Analysis in Help Center and File Exchange

Asked:

on 25 Aug 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!