Recreating an image with a Haar function basis instead of Fourier basis

46 Views Asked by At

I'm stuck on recreating an image with a Haar function basis. I already succeed to make it with a Fourier basis and I wanted to use a similar approach for a Haar basis. I found some valuables sources describing somewhat similar situations (in particular this article https://www.researchgate.net/publication/239609736_Image_Compression_using_Modified_Haar_Wavelet-Base_Vector_Quantization) but I have some troubles to implement (even for making a pseudo-code), especially how to code a correct 2D haar function. So for a Fourier basis, here is my (matlab) pseudo-code. MaxIndexX and MaxIndexY are used to choose how many functions I'm using and Lx / Ly are the size of the image and finally mu_k represents Fourier coefficient.

for i=1->MaxIndexX

for j=1->MaxIndexY

f_k(x,y)=cos((i-1) * pi * x/Lx)*cos((j-1) * pi * y/Ly)
mu_k=trapz(1:Ly,trapz(1:Lx,mu * f_k))

Of course I deleted some details (like my normalizing constant, etc) but this is the idea. Here my basis is composed of cos(..) * cos(..) and I wanted to use a 2D haar basis instead. There are some sources explaining this type of basis using 4 functions composed of one scaling function (for scaling) and three wavelets functions (for horizontal, vertical and diagonal purpose). As I understood, I should also transform my 2 for loops into 3 as a Haar basis uses 3 index but I don't understand how I should write my f_k (considering the 4 functions used) to proceed computing the Haar coefficient.