File: twoD.py

package info (click to toggle)
dipy 0.5.0-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,780 kB
  • sloc: python: 10,563; makefile: 218; pascal: 138
file content (20 lines) | stat: -rw-r--r-- 648 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import pylab as pl
import numpy as np
def imshow(array, cmap='gray',interpolation='nearest', alpha=1.0,
            vmin=None, vmax=None, origin=None, extent=None):
    """
    Wrapper for pylab.imshow that displays array values as well
    coordinate values with mouse over.
    """
    pl.imshow(array.T, cmap=cmap, interpolation=interpolation, alpha=alpha,
            vmin=vmin, vmax=vmax, origin=origin, extent=extent)
    ax = pl.gca()
    ax.format_coord = __report_pixel

def __report_pixel(x, y):
    x = np.round(x)
    y = np.round(y)
    v = pl.gca().get_images()[0].get_array()[y, x]
    return "x = %d y = %d v = %5.3f" % (x, y, v)