File: 2dtransform.rst

package info (click to toggle)
python-dtcwt 0.12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 8,404 kB
  • sloc: python: 6,253; sh: 29; makefile: 13
file content (36 lines) | stat: -rw-r--r-- 1,170 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
2D transform
------------

Using the pylab environment (part of matplotlib) we can perform a simple
example where we transform the standard 'mandrill' image and show the level 2
wavelet coefficients:

.. plot::
    :include-source: true

    # Load the mandrill image
    mandrill = datasets.mandrill()

    # Show mandrill
    figure(1)
    imshow(mandrill, cmap=cm.gray, clim=(0,1))

    import dtcwt
    transform = dtcwt.Transform2d()

    # Compute two levels of dtcwt with the defaul wavelet family
    mandrill_t = transform.forward(mandrill, nlevels=2)

    # Show the absolute images for each direction in level 2.
    # Note that the 2nd level has index 1 since the 1st has index 0.
    figure(2)
    for slice_idx in range(mandrill_t.highpasses[1].shape[2]):
        subplot(2, 3, slice_idx)
        imshow(np.abs(mandrill_t.highpasses[1][:,:,slice_idx]), cmap=cm.spectral, clim=(0, 1))

    # Show the phase images for each direction in level 2.
    figure(3)
    for slice_idx in range(mandrill_t.highpasses[1].shape[2]):
        subplot(2, 3, slice_idx)
        imshow(np.angle(mandrill_t.highpasses[1][:,:,slice_idx]), cmap=cm.hsv, clim=(-np.pi, np.pi))