[python-dtcwt] 442/497: remove ipython directive from Sphinx docs

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:06:36 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 ac72798fd5804faf84116c8e938a2ce435dbd1b2
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date:   Mon May 12 13:19:07 2014 +0100

    remove ipython directive from Sphinx docs
    
    The IPython directive appears broken with IPython 2.0. Since it was only
    used in one place, work around it.
---
 docs/conf.py          |   2 -
 docs/registration.rst | 171 +++++++++++++++++++++++++++++++++-----------------
 2 files changed, 113 insertions(+), 60 deletions(-)

diff --git a/docs/conf.py b/docs/conf.py
index 37f71cb..077379d 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -46,9 +46,7 @@ extensions = [
     'sphinx.ext.todo',
     'sphinx.ext.coverage',
     'sphinx.ext.mathjax',
-    'matplotlib.sphinxext.ipython_directive',
     'matplotlib.sphinxext.plot_directive',
-    'IPython.sphinxext.ipython_console_highlighting',
 ]
 
 # Add any paths that contain templates here, relative to this directory.
diff --git a/docs/registration.rst b/docs/registration.rst
index bc979ac..2e84fb0 100644
--- a/docs/registration.rst
+++ b/docs/registration.rst
@@ -260,113 +260,168 @@ As an example, we will register two frames from a video of road traffic.
 Firstly, as boilerplate, import plotting command from pylab and also the
 :py:mod:`datasets` module which is part of the test suite for :py:mod:`dtcwt`.
 
-.. ipython::
+.. code::
 
-    In [0]: from pylab import *
-
-    In [0]: import datasets
+    from pylab import *
+    import datasets
 
 If we show one image in the red channel and one in the green, we can see where
 the images are incorrectly registered by looking for red or green fringes:
 
-.. ipython::
+.. code::
 
-    @doctest
-    In [1]: ref, src = datasets.regframes('traffic')
+    ref, src = datasets.regframes('traffic')
 
-    In [1]: figure()
+    figure()
+    imshow(np.dstack((ref, src, np.zeros_like(ref))))
+    title('Registration input images')
 
-    In [3]: imshow(np.dstack((ref, src, np.zeros_like(ref))))
-    Out[3]: <matplotlib.image.AxesImage at 0x319d9d0>
+.. plot::
 
-    @savefig gen-registration-input.png align=center
-    In [4]: title('Registration input images')
-    Out[4]: <matplotlib.text.Text at 0x3193ad0>
+    from pylab import *
+    import datasets
 
-To register the images we first take the DTCWT:
+    ref, src = datasets.regframes('traffic')
 
-.. ipython::
-    :doctest:
+    figure()
+    imshow(np.dstack((ref, src, np.zeros_like(ref))))
+    title('Registration input images')
 
-    In [5]: import dtcwt
+To register the images we first take the DTCWT:
 
-    In [6]: transform = dtcwt.Transform2d()
+.. code::
 
-    In [7]: ref_t = transform.forward(ref, nlevels=6)
+    import dtcwt
 
-    In [8]: src_t = transform.forward(src, nlevels=6)
+    transform = dtcwt.Transform2d()
+    ref_t = transform.forward(ref, nlevels=6)
+    src_t = transform.forward(src, nlevels=6)
 
 Registration is now performed via the :py:func:`dtcwt.registration.estimatereg`
 function. Once the registration is estimated, we can warp the source image to
 the reference using the :py:func:`dtcwt.registration.warp` function.
 
-.. ipython::
+.. code::
 
-    In [9]: import dtcwt.registration as registration
+    import dtcwt.registration as registration
 
-    @doctest
-    In [10]: reg = registration.estimatereg(src_t, ref_t)
-
-    :doctest:
-    In [13]: warped_src = registration.warp(src, reg, method='bilinear')
+    reg = registration.estimatereg(src_t, ref_t)
+    warped_src = registration.warp(src, reg, method='bilinear')
 
 Plotting the warped and reference image in the green and red channels again
 shows a marked reduction in colour fringes.
 
-.. ipython::
+.. code::
+
+    figure()
 
-    In [1]: figure()
+    imshow(np.dstack((ref, warped_src, np.zeros_like(ref))))
+    title('Source image warped to reference')
 
-    In [14]: imshow(np.dstack((ref, warped_src, np.zeros_like(ref))))
-    Out[14]: <matplotlib.image.AxesImage at 0x3186d90>
+.. plot::
 
-    @savefig gen-registration-warped.png align=center
-    In [15]: title('Source image warped to reference')
+    from pylab import *
+    import datasets
+    ref, src = datasets.regframes('traffic')
+    import dtcwt
+    transform = dtcwt.Transform2d()
+    ref_t = transform.forward(ref, nlevels=6)
+    src_t = transform.forward(src, nlevels=6)
+    import dtcwt.registration as registration
+
+    reg = registration.estimatereg(src_t, ref_t)
+    warped_src = registration.warp(src, reg, method='bilinear')
+    figure()
+
+    imshow(np.dstack((ref, warped_src, np.zeros_like(ref))))
+    title('Source image warped to reference')
 
 The velocity field, in units of image width/height, can be calculated by the
 :py:func:`dtcwt.registration.velocityfield` function. We need to scale the
 result by the image width and height to get a velocity field in pixels.
 
-.. ipython::
+.. code::
 
-    @doctest
-    In [24]: vxs, vys = registration.velocityfield(reg, ref.shape[:2], method='bilinear')
+    vxs, vys = registration.velocityfield(reg, ref.shape[:2], method='bilinear')
+    vxs = vxs * ref.shape[1]
+    vys = vys * ref.shape[0]
 
-    In [0]: vxs = vxs * ref.shape[1]
+We can plot the result as a quiver map overlaid on the reference image:
 
-    In [0]: vys = vys * ref.shape[0]
+.. code::
 
+    figure()
 
-We can plot the result as a quiver map overlaid on the reference image:
+    X, Y = np.meshgrid(np.arange(ref.shape[1]), np.arange(ref.shape[0]))
+
+    imshow(ref, cmap=cm.gray, clim=(0,1))
 
-.. ipython::
+    step = 8
 
-    In [1]: figure()
+    quiver(X[::step,::step], Y[::step,::step],
+           vxs[::step,::step], vys[::step,::step],
+           color='g', angles='xy', scale_units='xy', scale=0.25)
 
-    In [26]: X, Y = np.meshgrid(np.arange(ref.shape[1]), np.arange(ref.shape[0]))
+    title('Estimated velocity field (x4 scale)')
 
-    In [27]: imshow(ref, cmap=cm.gray, clim=(0,1))
-    Out[27]: <matplotlib.image.AxesImage at 0x7ded610>
+.. plot::
 
-    In [25]: step = 8
+    from pylab import *
+    import datasets
+    ref, src = datasets.regframes('traffic')
+    import dtcwt
+    transform = dtcwt.Transform2d()
+    ref_t = transform.forward(ref, nlevels=6)
+    src_t = transform.forward(src, nlevels=6)
+    import dtcwt.registration as registration
 
-    In [28]: quiver(X[::step,::step], Y[::step,::step],
-       ....:        vxs[::step,::step], vys[::step,::step],
-       ....:        color='g', angles='xy', scale_units='xy', scale=0.25)
-    Out[28]: <matplotlib.quiver.Quiver at 0x7df1110>
+    reg = registration.estimatereg(src_t, ref_t)
+    warped_src = registration.warp(src, reg, method='bilinear')
 
-    @savefig gen-registration-vel-field.png align=center
-    In [29]: title('Estimated velocity field (x4 scale)')
+    vxs, vys = registration.velocityfield(reg, ref.shape[:2], method='bilinear')
+    vxs = vxs * ref.shape[1]
+    vys = vys * ref.shape[0]
+
+    figure()
+
+    X, Y = np.meshgrid(np.arange(ref.shape[1]), np.arange(ref.shape[0]))
+
+    imshow(ref, cmap=cm.gray, clim=(0,1))
+
+    step = 8
+
+    quiver(X[::step,::step], Y[::step,::step],
+           vxs[::step,::step], vys[::step,::step],
+           color='g', angles='xy', scale_units='xy', scale=0.25)
+
+    title('Estimated velocity field (x4 scale)')
 
 We can also plot the magnitude of the velocity field which clearly shows the moving cars:
 
-.. ipython::
+.. code::
+
+    figure()
+    imshow(np.abs(vxs + 1j*vys), cmap=cm.hot)
+    title('Velocity field magnitude')
+
+.. plot::
+
+    from pylab import *
+    import datasets
+    ref, src = datasets.regframes('traffic')
+    import dtcwt
+    transform = dtcwt.Transform2d()
+    ref_t = transform.forward(ref, nlevels=6)
+    src_t = transform.forward(src, nlevels=6)
+    import dtcwt.registration as registration
 
-    In [1]: figure()
+    reg = registration.estimatereg(src_t, ref_t)
+    warped_src = registration.warp(src, reg, method='bilinear')
 
-    In [30]: imshow(np.abs(vxs + 1j*vys), cmap=cm.hot)
-    Out[30]: <matplotlib.image.AxesImage at 0x7ded250>
+    vxs, vys = registration.velocityfield(reg, ref.shape[:2], method='bilinear')
+    vxs = vxs * ref.shape[1]
+    vys = vys * ref.shape[0]
 
-    @savefig gen-registration-vel-mag.png align=center
-    In [31]: title('Velocity field magnitude')
-    Out[31]: <matplotlib.text.Text at 0x3193ad0>
+    figure()
+    imshow(np.abs(vxs + 1j*vys), cmap=cm.hot)
+    title('Velocity field magnitude')

-- 
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