[iaplot] [Up] [iashow] Visualization

iasplot
Plot a surface.

Synopsis

g, d = iasplot( x = 0, y = None, z = None, filename = None )

Implemented in Python.

Input

x Image. Gray-scale (uint8 or uint16) or binary image (logical).

x range.

Default: 0

y Image. Gray-scale (uint8 or uint16) or binary image (logical).

y range.

Default: None

z Image. Gray-scale (uint8 or uint16) or binary image (logical).

object function (z=f(x,y)).

Default: None

filename String.

Name of the postscript file.

Default: None

Output

g String.

Gnuplot pointer.

d String.

Gnuplot data.

Description

Plot a 3D function z=f(x,y).

Examples

>>> x = Numeric.arange(35)/2.0

              
>>> y = Numeric.arange(30)/10.0 - 1.5

              
>>> def z(x,y): return 1.0 / (1 + 0.01 * x**2 + 0.5 * y**2)

              
>>> g,d = iasplot(x, y, z)
>>> 
x, y, z
>>> f = iaread('lenina.pgm')

              
>>> k = f[90:195, 70:150]

              
>>> iashow(k)
(105, 80) Min= 45 Max= 209 Mean=112.957 Std=32.77
>>> g,d = iasplot(k)
>>> g('set view 30,60')

              
>>> g.splot(d) # surface
>>> 
>>> g('set view 0,90')

              
>>> g('set nosurface') # level curves

              
>>> g.splot(d)
>>> 
k k
d d

Source Code

def iasplot(x=0, y=None, z=None, filename=None):
    import Numeric
    try:
        import Gnuplot
        import Gnuplot.funcutils
        g = Gnuplot.Gnuplot(debug=1)
        g('set parametric')
        g('set data style lines')
        g('set hidden')
        g('set contour base')
        f = Numeric.asarray(x)
        if y is None:
            x = range(f.shape[0])
            y = range(f.shape[1])
            def z(x, y, f=f):
                return f[int(x),int(y)]
        d = Gnuplot.funcutils.compute_GridData(x, y, z, binary=0)
        g.splot(d)
        if filename:
            g.hardcopy(filename, mode='portrait', enhanced=1, color=1)
    except:
        g,d = None,None
    return g, d
    
[iaplot] [Up] [iashow] http://www.python.org