# Larger image after wavelet reconstruction

Depending on the size of the original image and depending on the kind of padding used during 2D discrete wavelet transform and reconstruction, the reconstructed image has a larger size.

Is there a general method given a mxn matrix and given some padding mode to crop the obtained pxq matrix to the mxn matrix (without trying every possibility in order to find the one with the least error)?

• Since Wavelet Decomposition is just like Pyramid Decomposition, I also have the problem how to reconstruct the image. Moreover, things become harsher when you apply some processing to the different levels. – Royi Dec 3 '14 at 7:57
• @Drazick I now even face an even worser problem for the wavelet packet transform. I construct my tree of coefficients and find the best basis given a certain cost function. But during reconstruction when I try to merge the CA, CH, CV, CD coefficients (each one resulted from a previous merge), the merge (idwt2) fails because CA can be of smaller size than CD. – Matthias Dec 4 '14 at 21:00
• I'm not sure about the Wavelets Tree. Can you make it any equivalent to the pyramid? – Royi Dec 10 '14 at 16:26
• @Drazick you said yourself they're equivalent? The discrete wavelet packet transform performs one step of a discrete wavelet transform of the original image resulting in four coefficient matrices CA, CH, CV, CD. This is repeated for each coefficient matrix etc. So you get 4, 16, 64, etc. coefficient matrices after 1, 2, 3, etc. decomposition steps. So the wavelet coefficients (CH, CV, CD) are also decomposed in comparison with the discrete wavelet transform which only decomposes the scaling (CA) coefficients. – Matthias Dec 10 '14 at 18:03
• @Drazick when the tree is constructed, the optimal basis is retrieved given some additive cost function in 'O(n log n)'. During reconstruction 4 nodes of the tree are combined to their parent till we only have one node (the reconstruction). – Matthias Dec 10 '14 at 18:05

A more lazy option (if I remember well) is to use a pair of symmetric/anti-symmetric $$M$$-band wavelets, over $$J$$ levels. If you expand the image to a size that can be divided by $$J^M$$ (the most symmetrically as you can), and use a symmetric extension that may reveal non-expansive if properly tuned. This may vary with implementations.