-1

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.

Jogging Song
  • 573
  • 6
  • 28

1 Answers1

2

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 two 0 values, or 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!

rayryeng
  • 102,964
  • 22
  • 184
  • 193