When Using the Discrete Wavelet transform using a Haar filter, i get negative values and the dynamic range goes up to well over 400

6 views (last 30 days)
I am currently using DWT2 and SWT2 to perform a wavelet transform using the Haar wavelet. How is it possible that the LL matrix contains negative values and values of 400, if the formula is basically an average of the odd and even coloumns/rows ?
  3 Comments
Daniel
Daniel on 7 Feb 2014
Thank you for your reply. In the attachment you have the LL matrix of 256x256 Lena. The matrix was generated using the haar wavelet transform using the stationary wavelet transform of matlab.
Wayne King
Wayne King on 12 Feb 2014
Hi Daniel, If I am going to be able to explain how the LL image from the DWT ends up producing certain values, I need the original data, not the LL matrix. Why don't you attach or send me that actual Lena image?

Sign in to comment.

Accepted Answer

Wayne King
Wayne King on 13 Feb 2014
Edited: Wayne King on 13 Feb 2014
Hi Daniel, I surprised you say that the LL image contains negative values. That I don't observe (nor would I expect it) for your data
im = imread('lena.bmp');
dwtmode('per')
[LL,LH,HL,HH] = dwt2(im,'haar');
isempty(find(LL<0))
You should get a 1 to indicate that there are no elements less than 0
Now to explain that you observe elements in the LL image with values larger than the original image.
Yes, that is expected. Here's why. With a 2-D separable wavelet transform you end up with a sum of averages in the LL image, so at a given element of the LL image you will have something like: 1/2(a+b)+1/2(a+b) = a+b
as a result you are likely to get elements up to twice in value of the original elements.
Here is a very simple example of that:
X = ones(4);
[LL,LH,HL,HH] = dwt2(X,'haar');
LL
You see the output LL image is [2 2; 2 2] where the elements are all of the form
1/2(1+1)+1/2(1+1)
Here is showing you exactly how that is obtained:
X = ones(4);
Lo_D = [1/sqrt(2) 1/sqrt(2)]; %Haar scaling filter
Y = conv2(X,Lo_D(:)','valid'); %filter along the columns
Y(:,end+1) = Y(:,end); % periodically extend the matrix for the next step
Y = Y(:,2:2:end); % downsample along the columns
Y(end+1,:) = Y(end,:); %periodically extend the rows for the next step
Y = conv2(Y',Lo_D(:)','valid'); % filter along the rows
Y = Y';
Y = Y(1:2:end,:) %downsample
Compare the Y matrix to the LL matrix obtained from dwt2()
  1 Comment
Daniel
Daniel on 20 May 2014
Edited: Daniel on 21 May 2014
Hi wayne. ive implemented this and it works than k you very much. in the inverse DWT, you have to use the same problem but instead of downsampling after convolution you have to upsample before convolution?
cheers :)

Sign in to comment.

More Answers (0)

Categories

Find more on Discrete Multiresolution Analysis in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!