0
$\begingroup$

I am learning wavelet theory for image processing. To understand the theory, I write one Matlab program to decompose one black-white image. The program is as follows

 Image = zeros(256, 256, 'uint8');
 Image(101:200, 101:200) = 255;
 figure; imshow(Image);
 [cA1, cH1, cV1, cD1] = dwt2(Image, 'db1');
 Image1 = [cA1, cH1; cV1, cD1];
 figure; imshow(Image1, []);
 [cA1, cH1, cV1, cD1] = dwt2(Image, 'db2');
 Image1 = [cA1, cH1; cV1, cD1];
 figure; imshow(Image1, []);

The first decomposition using the argument db1 produces zeros for all wavelet coefficients. The black-white image has the transition from 0 to 255 along horizontal and vertical directions and should have high-frequency component. Why are zero wavelet coefficients generated? If I change the argument from db1 to db2, the result will show horizontal and vertical lines in the subbands.

Edit: I decompose the image further and at level 3 edge-like structure can be seen on the subband. Wavelet is one kind of filter bank I read from one book. It means the frequency in the image can only be seen in the higher frequency band. From the below link, it told how to get frequency response of Daubechies filters.

http://www.mathworks.com/matlabcentral/answers/44879-daubechies-filters-frequency-response

I don't understand how is the frequency for images defined. From one book, it says that "Spatial frequencies are measures of the number of oscillations (cycles) from dark to light per unit of length of the image". How can I know the frequencies in the input image.

$\endgroup$
1
$\begingroup$

If you recall, db1 is the Haar Wavelet. The Haar Wavelet takes either an average of pixels within local windows for the approximation coefficients (or the LL band), or a difference of pixels within local windows for the detail coefficients (or the LH, HL and HH bands).

Be advised that the input image that you specified only consists of two intensities: 0 and 255. Also, you set a square grid within this image to be 255 and it is uniformly shaped.

For self-containment, this is what your test image looks like:

enter image description here

This uniformly shaped object within a square image is important as part of the reasoning why you are not getting any output for the detail images (HL, LH, and HH).

The best way to describe why you're seeing an output for db2 and not db1 can be shown visually.

This slide is from the University of Toronto's CS 320: Introduction to Visual Computing course, specifically, the Discrete Wavelet Transform lecture:

enter image description here

You are well aware that when you take the 2D DWT, you produce 4 sub-images that are half the resolution of the original image. The first output of dwt2 are the approximation coefficients where each output pixel is an average of a 2 x 2 window. The other outputs (second, third and fourth) are detail windows that take two pixels within the window and subtracts these with two other pixels in the window.

As such, the reason why you are not getting an output with db1 is because all of your calculations for the detail images will cancel out. Specifically, you will get 2 x 2 windows of either completely 0, or completely 255, and when you calculate the detail images, you will get 0s for the output regardless. You would take add two 0 values, or two 255 values and you would subtract these with two other 0 values, or two other 255 values respectively, thus causing the output to be 0 regardless.

The db2 wavelet is a more complicated transform which is a weighted sum of non-uniform coefficients and so you will certainly get outputs for the detail images rather than just a simple differencing of the 2 x 2 windows.

I would like to stress that if you have a more complicated shape that is non-uniform, db1 will certainly not give you a zero output. Try it on any test image that comes with MATLAB, like with cameraman.tif.


Hope this helps!

$\endgroup$
  • $\begingroup$ It is really helpful. I edit the problem and add my new finding. $\endgroup$ – Jogging Song Feb 9 '15 at 2:29
0
$\begingroup$

For me, this does not make any sense. One possible reason why you did not see such edge-like high-frequency components in db1 is that they are very thin (1 pixel wide), unless you zoom in you might miss them due to the interpolations happen in displaying an image. I suggest you to inspect matrix elements directly, namely counting the number of nonzero elements.

$\endgroup$
  • $\begingroup$ The minimum and maximum of wavelet coefficients are both zeroes. So I am sure all wavelet coefficients are zeroes. $\endgroup$ – Jogging Song Feb 9 '15 at 2:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.