[python-dtcwt] 399/497: make 3d directionality example be built at docs compile time
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:06:32 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 2e35c9e67773e2d86933a2acd75514b721865121
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date: Mon Feb 10 17:35:26 2014 +0000
make 3d directionality example be built at docs compile time
---
{examples => docs}/3d_dtcwt_directionality.py | 32 +++++++++++++--------------
docs/examples.rst | 24 +++++++++-----------
2 files changed, 26 insertions(+), 30 deletions(-)
diff --git a/examples/3d_dtcwt_directionality.py b/docs/3d_dtcwt_directionality.py
similarity index 96%
rename from examples/3d_dtcwt_directionality.py
rename to docs/3d_dtcwt_directionality.py
index 78fc2f1..effd505 100644
--- a/examples/3d_dtcwt_directionality.py
+++ b/docs/3d_dtcwt_directionality.py
@@ -23,34 +23,34 @@ from dtcwt.coeffs import biort, qshift
def main():
GRID_SIZE = 128
SPHERE_RAD = int(0.45 * GRID_SIZE) + 0.5
-
+
# Compute an image of the sphere
grid = np.arange(-(GRID_SIZE>>1), GRID_SIZE>>1)
X, Y, Z = np.meshgrid(grid, grid, grid)
r = np.sqrt(X*X + Y*Y + Z*Z)
sphere = (0.5 + np.clip(SPHERE_RAD-r, -0.5, 0.5)).astype(np.float32)
-
+
# Specify number of levels and wavelet family to use
nlevels = 2
b = biort('near_sym_a')
q = qshift('qshift_a')
-
+
# Form the DT-CWT of the sphere. We use discard_level_1 since we're
# uninterested in the inverse transform and this saves us some memory.
Yl, Yh = dtwavexfm3(sphere, nlevels, b, q, discard_level_1=False)
-
+
# Plot maxima
figure(figsize=(8,8))
-
+
ax = gcf().add_subplot(1,1,1, projection='3d')
ax.set_aspect('equal')
ax.view_init(35, 75)
-
+
# Plot unit sphere +ve octant
thetas = np.linspace(0, np.pi/2, 10)
phis = np.linspace(0, np.pi/2, 10)
-
-
+
+
tris = []
rad = 0.99 # so that points plotted latter are not z-clipped
for t1, t2 in zip(thetas[:-1], thetas[1:]):
@@ -61,18 +61,18 @@ def main():
sphere_to_xyz(rad, t2, p2),
sphere_to_xyz(rad, t2, p1),
])
-
+
sphere = Poly3DCollection(tris, facecolor='w', edgecolor=(0.6,0.6,0.6))
ax.add_collection3d(sphere)
-
+
locs = []
scale = 1.1
- for idx in xrange(Yh[-1].shape[3]):
+ for idx in range(Yh[-1].shape[3]):
Z = Yh[-1][:,:,:,idx]
C = np.abs(Z)
max_loc = np.asarray(np.unravel_index(np.argmax(C), C.shape)) - np.asarray(C.shape)*0.5
max_loc /= np.sqrt(np.sum(max_loc * max_loc))
-
+
# Only record directions in the +ve octant (or those from the -ve quadrant
# which can be flipped).
if np.all(np.sign(max_loc) == 1):
@@ -81,18 +81,18 @@ def main():
elif np.all(np.sign(max_loc) == -1):
locs.append(-max_loc)
ax.text(-max_loc[0] * scale, -max_loc[1] * scale, -max_loc[2] * scale, str(idx+1))
-
+
# Plot all directions as a scatter plot
locs = np.asarray(locs)
ax.scatter(locs[:,0], locs[:,1], locs[:,2], c=np.arange(locs.shape[0]))
-
+
w = 1.1
ax.auto_scale_xyz([0, w], [0, w], [0, w])
-
+
legend()
title('3D DT-CWT subband directions for +ve hemisphere quadrant')
tight_layout()
-
+
show()
def sphere_to_xyz(r, theta, phi):
diff --git a/docs/examples.rst b/docs/examples.rst
index 9a53557..58d20dd 100644
--- a/docs/examples.rst
+++ b/docs/examples.rst
@@ -6,14 +6,14 @@ Example scripts
Showing 3D Directional Sensitivity
----------------------------------
-The
-:download:`3d_dtcwt_directionality.py<../examples/3d_dtcwt_directionality.py>`
-script in the examples directory shows how one may demonstrate the directional
+The :download:`3d_dtcwt_directionality.py<3d_dtcwt_directionality.py>` script
+in the ``docs/`` directory shows how one may demonstrate the directional
sensitivity of the 3D DT-CWT complex subband coefficients. It computes
empirically the maximally sensitive directions for each subband and plots them
in an interactive figure using matplotlib. A screenshot is reproduced below:
-.. image:: 3d_dtcwt_directionality.png
+.. plot:: 3d_dtcwt_directionality.py
+ :class: align-center
There are some points to note about this diagram. Each subband is labeled sich
that '1' refers to the first subband, '5' the fifth and so forth. On this
@@ -23,20 +23,15 @@ hemisphere reflecting the position of subband 1. There are seven visible
subband directions in the +ve quadrant of the hemisphere and hence there are 28
directions in total over all four quadrants.
-The source for the script is shown below:
-
-.. literalinclude:: ../examples/3d_dtcwt_directionality.py
-
2D Image Registration
---------------------
This library includes support for 2D image registration modelled after the 3D
-algorithm outlined in the paper `Efficient Registration of Nonrigid 3-D Bodies`_.
-The
-:download:`image-registration.py<image-registration.py>`
-script in the examples directory shows a complete worked example of using the
-registration API using two sets of source images: a woman playing tennis and some
-traffic at a road junction.
+algorithm outlined in the paper `Efficient Registration of Nonrigid 3-D
+Bodies`_. The :download:`image-registration.py<image-registration.py>` script
+in the ``docs/`` directory shows a complete worked example of using the
+registration API using two sets of source images: a woman playing tennis and
+some traffic at a road junction.
.. _Efficient Registration of Nonrigid 3-D Bodies: http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=5936113
@@ -44,4 +39,5 @@ It will attempt to register two image pairs: a challenging sequence from a
video sequence and a sequence from a traffic camera. The result is shown below.
.. plot:: image-registration.py
+ :class: align-center
--
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