1
$\begingroup$

I am unable to understand the discrete wavelet transform on images. I followed Robi Polikar's tutorial and got a brief idea about the theory. But I'm unable to understand w.r.t images.

Using Matlab's ndwt2('chess.jpg', 2, 'haar') function on the chess board , I obtained the other 7 images in the album. (Link to the album given in the end)

ndwt2() returns a structure, whose member dec contains the approximation (A), horizontal (H) , vertical (V) and diagonal (D) details.

This is where I have problem. What does A, H, V and D details of the image mean?

Also, how come is 1st image in the album approximation of the chessboard (assuming approximation means a rough estimate of the image) ? It just has lines where the borders of chess boxes are there. How is that an approximation, or have I understood it wrong?

EDIT

I was doing the mistake of converting the datatype of image returned by ndwt2 (which is the double datatype) to uint8.

these are the images that I now get.

Why does H details image contains some V details also, though the V in H are noisy? Same for V, it also contains some H details.

This was not the case previously, there H had exclusively vertical lines, V had only horizontal details, D was blank.

previous album

$\endgroup$

1 Answer 1

3
$\begingroup$

One can implement the standard discrete wavelet transform (DWT) on an image (dwt2 in Matlab) with a series of filtering and decimation operations, on the rows and the columns. And the wavelet by itself results from the iteration at different levels.

Start with the Haar wavelet. In 1D, it can be implemented by a series of sums and differences ($[1,1]$ and $[1,-1]$ filter) on $2$-pixel sets. If you combine these two filters on the rows and the colums, you get $4$ possible combinations. They are illustrated in the four $2\times 2$ matrices.

One level wavelet decomposition

So take the small $2\times 2$ block from the hat (left image). If you sum the pixels on the rows and the columns, you globally sum all four pixels. That gives you the top-left cyan on the right image. If you repeat the process on all $2\times 2$ blocks, you get the top-left small image, often called the approximation at level 1 (A1). If you apply $[1,-1]$ on the rows, and sum the columns, you get the top-right small image. The difference along the rows detect some vertical details, as you can see (more or less vetical edges). It is called vertical details at level 1 (V1). Now, if you apply $[1,-1]$ on the columns, and sum the rows, you get the bottom-left small image, which detects some more of less horizontal details, called H1. The bottom-left small image computes differences on both rows and columns. It is called D1 for diagonal, though it is not very precise, in general, at detecting $\pm 45°$ edges.

There, you have A, H, V and D. A standard DWT further decomposes the small top-left image. With the same reasoning, you get approximation, vertical, horizontal and "diagonal" details at a second level (the $2$ in your comand):A2, D2, H2, V2.

Since A1 has been decomposed, you are left with A2, V2, H2, D2, V1, H1 and D1, hence $7$ images. With the DWT, those images are smaller (by $4 \times 4$ and $2 \times 2$).

Here, we have taken separate original $2 \times 2$ blocks. Another word for it is decimation, by $2$, after each filter pass.

Wiht ndwt2, the main difference is that you do not decimate, it is like taking blocks with overlap. So, normally, the A, V, H, D images look about the same, except they have almost the same size as the original (up to border effects and extension).

I am surprised by the apprroximation you show. Indeed, I believe there is a read or format issue with it. Open it with an image editor, save it again an a new JPG or PNG seems to fix the problem.

$\endgroup$
4
  • $\begingroup$ I was doing a big mistake. I don't know how I ended up doing that, but before saving the images obtained from ndwt, which are of double data type, I was converting them to uint8 !! I really don't remember why I was doing this. Now I have updated the album of the images I get. Now H details contains some V details, V contains some H. Unlike the previous album, where H had only horizontal lines from the chessboard, V had exclusively vertical lines. Why do you suppose this happened? Isn't it wrong? $\endgroup$
    – whatdoisay
    Commented Mar 2, 2016 at 6:20
  • $\begingroup$ Depending on the code, the location of the H and V can be swapped. Also, with the Haar wavelet especially, some lines won't appear, because of the index parity of the pixels. $[0,0,1,1]$ is a jump, but may not be detected at the first level. Try other wavelets as well. Oddly, the JPEG file I downloaded seemed to possess a PNG header, and was close to the A2 image. Hope this helps $\endgroup$ Commented Mar 2, 2016 at 10:38
  • $\begingroup$ Which image did you get as a PNG? $\endgroup$
    – whatdoisay
    Commented Mar 2, 2016 at 14:29
  • $\begingroup$ The initial 'chess.jpg', which I downloaded in jpg. I opened it with an hex editor, and saw a png header $\endgroup$ Commented Mar 2, 2016 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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