[python-dtcwt] 323/497: docs: replace 2d transform example with plot directive

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:06:21 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/sid
in repository python-dtcwt.

commit dade51cdefbada4d8316de4f489caac0758035ad
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date:   Sat Feb 1 13:03:27 2014 +0000

    docs: replace 2d transform example with plot directive
---
 docs/2dtransform.rst |  45 ++++++++++++++-------------------------------
 docs/lena-1.png      | Bin 239625 -> 0 bytes
 docs/lena-2.png      | Bin 340068 -> 0 bytes
 docs/lena-3.png      | Bin 678639 -> 0 bytes
 4 files changed, 14 insertions(+), 31 deletions(-)

diff --git a/docs/2dtransform.rst b/docs/2dtransform.rst
index a0ccf8f..f297dd2 100644
--- a/docs/2dtransform.rst
+++ b/docs/2dtransform.rst
@@ -3,51 +3,34 @@
 
 Using the pylab environment (part of matplotlib) we can perform a simple
 example where we transform the standard 'Lena' image and show the level 2
-wavelet coefficients::
+wavelet coefficients:
 
-    # Load the Lena image from the Internet into a StringIO object
-    from StringIO import StringIO
-    from urllib2 import urlopen
-    LENA_URL = 'http://www.ece.rice.edu/~wakin/images/lena512.pgm'
-    lena_file = StringIO(urlopen(LENA_URL).read())
+.. plot::
+    :include-source: true
 
-    # Parse the lena file and rescale to be in the range (0,1]
-    from scipy.misc import imread
-    lena = imread(lena_file) / 255.0
+    # Load the Lena image
+    lena = datasets.lena()
 
-    from matplotlib.pyplot import *
-    import numpy as np
-
-    # Show lena on the left
+    # Show lena
     figure(1)
     imshow(lena, cmap=cm.gray, clim=(0,1))
 
-    import dtcwt
+    import dtcwt.backend.backend_numpy as backend
+    transform = backend.Transform2d()
 
     # Compute two levels of dtcwt with the defaul wavelet family
-    Yh, Yl = dtcwt.dtwavexfm2(lena, 2)
+    lena_t = transform.forward(lena, 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 xrange(Yl[1].shape[2]):
+    for slice_idx in range(lena_t.subbands[1].shape[2]):
         subplot(2, 3, slice_idx)
-        imshow(np.abs(Yl[1][:,:,slice_idx]), cmap=cm.spectral, clim=(0, 1))
-        
+        imshow(np.abs(lena_t.subbands[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 xrange(Yl[1].shape[2]):
+    for slice_idx in range(lena_t.subbands[1].shape[2]):
         subplot(2, 3, slice_idx)
-        imshow(np.angle(Yl[1][:,:,slice_idx]), cmap=cm.hsv, clim=(-np.pi, np.pi))
-
-    show()
-
-If the library is correctly installed and you also have matplotlib installed,
-you should see these three figures:
-
-.. figure:: lena-1.png
-
-.. figure:: lena-2.png
-
-.. figure:: lena-3.png
+        imshow(np.angle(lena_t.subbands[1][:,:,slice_idx]), cmap=cm.hsv, clim=(-np.pi, np.pi))
 
diff --git a/docs/lena-1.png b/docs/lena-1.png
deleted file mode 100644
index 540e0f7..0000000
Binary files a/docs/lena-1.png and /dev/null differ
diff --git a/docs/lena-2.png b/docs/lena-2.png
deleted file mode 100644
index 5e3e406..0000000
Binary files a/docs/lena-2.png and /dev/null differ
diff --git a/docs/lena-3.png b/docs/lena-3.png
deleted file mode 100644
index 3360ffe..0000000
Binary files a/docs/lena-3.png and /dev/null differ

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-dtcwt.git



More information about the debian-science-commits mailing list