matlabhaar-wavelet

compressive sensing and Haar wavelet


I want to use CS to reconstruct an image from fewer samples.

I use Gaussian random matrix as measurement matrix. My problem is with Psi matrix which I want to be Haar wavelet coefficients but I don't know how to define it.

I have used DCT and Fourier basis and it worked well. Here is my code with Fourier basis.

Can anyone tell me how to define Psi matrix as haar wavelet transform?

Thanks in advance.

clc
clear all
close all
[fn,fp]=uigetfile({'*.*'});
tic 
A=im2double(rgb2gray(imread([fp,fn])));
figure(1),imshow(A)
xlabel('original')
x=A(:);
n=length(x);
m=1900;
Phi=randn(m,n);   %Measurment Matrix
Psi=fft(eye(n));   %sensing Matrix( or can be dct(eye(n)) )
y=Phi*x;  %compressed signal
Theta=Phi*Psi;
%Initial Guess:  y=Theta*s => s=Theta\y
s2=Theta\y;
%Solution
s1=OMP( Theta, y, 1e-3);
%Reconstruction
x1=Psi*s1;
figure,imshow(reshape(x1,size(A))),xlabel('OMP')
toc

Solution

  • You just need to generate a haar matrix of appropriate dimensions. Consider this MATLAB function:

    function [h]=haargen(N)
    % Generating Haar Matrix
    ih=zeros(N,N); 
    h(1,1:N)=ones(1,N)/sqrt(N);
    for k=1:N-1 
    p=fix(log(k)/log(2)); 
    q=k-(2^p); 
    k1=2^p; t1=N/k1; 
    k2=2^(p+1); t2=N/k2; 
    for i=1:t2 
    h(k+1,i+q*t1)   = (2^(p/2))/sqrt(N); 
    h(k+1,i+q*t1+t2)    =-(2^(p/2))/sqrt(N); 
    end 
    

    end