# How do I implement the CDF wavelet inverse?

I understand and have implemented a 2D discrete wavelet transform that uses a Haar wavelet to process images.

Now I would like to implement a 2D Cohen-Daubechies-Feauveau wavelet transform, but I am uncertain about how to do the inverse transform.

The Haar transform uses a 2x2 kernel, so I have 4 coefficients for each 2x2 block of pixels, and it's obvious to me how to reverse transform to reconstruct my pixels.

The CDF wavelet uses odd tap filters, so at each image location (i,j), I have 4 coefficients. It seems, therefore, that there is no need to downsample -- I can simply get 4 coefficient images, where each is the same size as the original image, and then run the reverse transform on those four images to reconstruct the original. Is that correct?

This is the method I tried, but it does not restore the image -- it just gives me garbage.

If A is the low pass filter and B is the high pass filter, x is the image, and x(A,B) means apply filter A to x horizontally and B to x vertically:

1. x1 = x(A,A)
2. x2 = x(A,B)
3. x3 = x(B,A)
4. x4 = x(B,B)
5. y1 = x1(B,B)
6. y2 = x2(B,A)
7. y3 = x3(A,B)
8. y4 = x4(A,A)

Sum y1, y2, y3, y4 to get original image, x.

Does this method look correct?

I am certain that I am doing the forward transform correctly, but I am unsure about the reverse transform. I have read the Wikipedia article on Fast Wavelet Transform, and I believe that I am implementing what this page states (without the downsampling).

To the contrary, the odd tap filters allow you to keep everything perfectly symmetric. If you make the filter centered at $0$, then the application of the filter at position $i$ requires a symmetric range of coefficients around $i$.

All 2-channel wavelets will produce a quad-tree decomposition of a 2D image, regardless of tap length. The only complication of longer, non-trivial wavelet filter banks is the treatment of the boundaries. Here one has an advantage in using symmetric filters. (Symmetric and orthogonal wavelet filters exist for 3-channel, 4-channel wavelets and so on. See articles by Heller, Belogay/Wang, Turcajeva.)

If you continue the image by mirroring at the boundaries, the transformed image will also have odd or even symmetry at the boundaries so that the size of the transformed image can be kept equal to the size of the original image.

In the reconstruction process, you have to reconstruct those mirrored coefficients in the bands and then apply the centered filters to obtain the original image back.

• Indeed, that's why I want to use CDF instead of Haar -- so that I can get 4 coefficients at each pixel location without introducing any shifting. (I misspoke about it being 'asymmetric' in my original question and have edited the OP.) But my question remains: What do I do with those 4 coefficients to reconstruct the original pixel?
– jsp
Jan 18, 2014 at 19:24

It's possible that you get a small shift with forward/backward transforms. This is especially the case if you're trying to keep your 1D filters causal (no future data needed). Anyway, Wikipedia gives you the basic form for the inverse transform: you apply the two kernels in reverse to the sand d terms & sum the two contributions. Don't mind the