[python-dtcwt] 416/497: Renamed quiver function to overlay_quiver, now works with more than just DTCWT
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:06:34 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 af1d1baaa70685fea56ccbb66427189545c46f43
Author: scf32 <scf32 at cam.ac.uk>
Date: Fri Feb 14 13:40:24 2014 +0000
Renamed quiver function to overlay_quiver, now works with more than just DTCWT
---
dtcwt/plotting.py | 61 ++++++++++++++++++++++++-------------------------------
1 file changed, 26 insertions(+), 35 deletions(-)
diff --git a/dtcwt/plotting.py b/dtcwt/plotting.py
index b07da56..d118292 100644
--- a/dtcwt/plotting.py
+++ b/dtcwt/plotting.py
@@ -9,49 +9,37 @@ import numpy as np
from matplotlib.pyplot import *
__all__ = (
- 'overlay_quiver_DTCWT',
+ 'overlay_quiver',
)
-def overlay_quiver_DTCWT(image, vectorField, level, offset):
+def overlay_quiver(image, vectorField, level, offset):
"""Overlays nicely coloured quiver plot of complex coefficients over original full-size image,
- providing a useful phase visualisation.
-
- :param image: array holding grayscale values on the interval [0, 255] to display
- :param vectorField: a single [MxNx6] numpy array of DTCWT coefficients
- :param level: the transform level (1-indexed) of *vectorField*.
- :param offset: Offset for DTCWT coefficients (typically 0.5)
-
- .. note::
-
- The *level* parameter is 1-indexed meaning that the third level has
- index "3". This is unusual in Python but is kept for compatibility
- with similar MATLAB routines.
-
- Should also work with other types of complex arrays (e.g., SLP
- coefficients), as long as the format is the same.
-
+ providing a useful phase visualisation. image should be of type UINT8. vectorField is a single
+ [MxNx6] numpy array of DTCWT coefficients, level specifies the transform level of vectorField.
+ Offset for DTCWT coefficients is typically 0.5. Should also work with other types of complex
+ arrays (e.g., SLP coefficients), as long as the format is the same.
+
Usage example:
-
- .. plot::
- :include-source: true
-
- import dtcwt
- import dtcwt.plotting as plotting
-
- lena = datasets.lena()
-
- transform2d = dtcwt.Transform2d()
- lena_t = transform2d.forward(lena, nlevels=5)
-
- plotting.overlay_quiver_DTCWT(lena*255, lena_t.highpasses[-1], 5, 0.5)
-
+
+ .. ipython::
+
+ In [0]: lena = datasets.lena()
+
+ In [0]: lena_t = transform2d.forward(lena, nlevels=3)
+
+ In [0]: figure()
+
+ @savefig gen-overlay_quiver.png
+ In [0]: dtcwtplt.overlay_quiver(lena, lena_t.subbands[-1], 3, 0.5)
+
.. codeauthor:: R. Anderson, 2005 (MATLAB)
.. codeauthor:: S. C. Forshaw, 2014 (Python)
"""
# Make sure imshow() uses the full range of greyscale values
imshow(image, cmap=cm.gray, clim=(0,255))
-
+ hold(True)
+
# Set up the grid for the quiver plot
g1 = np.kron(np.arange(0, vectorField[:,:,0].shape[0]).T, np.ones((1,vectorField[:,:,0].shape[1])))
g2 = np.kron(np.ones((vectorField[:,:,0].shape[0], 1)), np.arange(0, vectorField[:,:,0].shape[1]))
@@ -60,11 +48,14 @@ def overlay_quiver_DTCWT(image, vectorField, level, offset):
cmap = cm.spectral
scalefactor = np.max(np.max(np.max(np.max(np.abs(vectorField)))))
vectorField[-1,-1,:] = scalefactor
-
+
+ print(scalefactor)
for sb in range(0, vectorField.shape[2]):
+ hold(True)
thiscolour = cmap(sb / float(vectorField.shape[2])) # Select colour for this subband
hq = quiver(g2*(2**level) + offset*(2**level), g1*(2**level) + offset*(2**level), np.real(vectorField[:,:,sb]), \
np.imag(vectorField[:,:,sb]), color=thiscolour, scale=scalefactor*2**level)
- quiverkey(hq, 1.05, 0.9-0.05*sb, 0, "subband " + np.str(sb), coordinates='axes', color=thiscolour, labelcolor=thiscolour, labelpos='E')
+ quiverkey(hq, 1.05, 1.00-0.035*sb, 0, "subband " + np.str(sb), coordinates='axes', color=thiscolour, labelcolor=thiscolour, labelpos='E')
+ hold(False)
return hq
--
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