From: fiatlux on
Hi

First of all, sorry for my English.
I have a 512x512 grayscale image. I want to perform a single-level 2D-wavelet transform on it, so I just use the dwt2 function. I want the 4 resulting subbands images to be 256x256 images. I look in the help for the dwt2 function and it says that, if sx=size of image=512 in my case, the size of those 4 subband images will be set to ceil(sx/2), if the DWT extension mode is set to symmetric padding. And they even give and example:
[cA,cH,cV,cD] = dwt2(x,'db8','mode','sym');
Here x is the 512x512 image and 'db8' is the filter I want to use. This filter will increase the width and height of the images by N-1=7 pixels, but then the image should be put back to 256x256 with 'mode','sym'.

My problem is that when I do that, the 4 resulting images have a size of 263x263 instead of 256x256, as if matlab did not take into account the fact that I wrote "'mode','sym'"....

Can anybody help me please? Thanks in advance!
From: Wayne King on
fiatlux <dexm47(a)hotmail.fr> wrote in message <1509425261.246725.1275161189478.JavaMail.root(a)gallium.mathforum.org>...
> Hi
>
> First of all, sorry for my English.
> I have a 512x512 grayscale image. I want to perform a single-level 2D-wavelet transform on it, so I just use the dwt2 function. I want the 4 resulting subbands images to be 256x256 images. I look in the help for the dwt2 function and it says that, if sx=size of image=512 in my case, the size of those 4 subband images will be set to ceil(sx/2), if the DWT extension mode is set to symmetric padding. And they even give and example:
> [cA,cH,cV,cD] = dwt2(x,'db8','mode','sym');
> Here x is the 512x512 image and 'db8' is the filter I want to use. This filter will increase the width and height of the images by N-1=7 pixels, but then the image should be put back to 256x256 with 'mode','sym'.
>
> My problem is that when I do that, the 4 resulting images have a size of 263x263 instead of 256x256, as if matlab did not take into account the fact that I wrote "'mode','sym'"....
>
> Can anybody help me please? Thanks in advance!

Hi, That is a typo in the documentation. It should read

Let sx = size(X) and lf = the length of filters; then size(cA) = size(cH) = size(cV) = size(cD) = sa where sa = ceil(sx/2), if the DWT extension mode is set to periodization. For the other extension modes, sa = floor((sx+lf-1)/2).

The behavior you expect would be valid if the dwtmode were set to 'per'. The function is actually behaving correctly.

Hope that helps,
Wayne
From: fiatlux on
Thanks a lot! It works now :)