[SciPy-User] [SciPy-user] 3D interpolation

Burak1327 burak.o.cankurtaran at alumni.uts.edu.au
Tue Dec 29 08:26:49 EST 2009


Thank you everyone for your replies.

I tried Vincent's advice, and it seems to work. Though, the overshoot is
much more
than 20% in this case. Below I listed the minimum and maximum values
of the data set, after interpolation at different orders:

Raw Data
Minimium Value : -3118.532224
Maximum Value : 0.0 (There next value is about -3115)

Order = 0
Minimium Value : -3118.532224
Maximum Value : 0.0

Order = 1
Minimium Value : -3118.532224
Maximum Value : 0.0

Order = 2
Minimium Value : -3905.68081297
Maximum Value : 851.160340484

Order = 3
Minimium Value : -4077.10199215
Maximum Value : 1028.48609365

Thanks
Burak


denis-bz-gg wrote:
> 
> Vincent, you're right, splines can overshoot, though not by a lot:
> 0 1 1 0 overshoots by 20 % in the code snippet below.
> Burak, does order=1, just averaging 8 neighbors, work ?
> 
> There are many kinds of cubic splines, including
> -- global cubic, which map_coordinates seems to use
> -- local B-spline: does not interpolate, go through the input points,
>     but can't overshoot, stays in the convex hull of the input points
> -- local Catmull-Rom: interpolates, but can overshoot (over shoots and
> leaves :)
>     ("Local" means that e.g. in 1d, out[ 3 to 4 ] is calculated from
> the 4 nearest input points at 2 3 4 5,
>     or equivalently that in[3] affects only out[ 1 to 5 ]: a desirable
> property.)
> 
> Different corners of Scipy have different spline routines, some with
> doc.
> To see exactly what they do, you can only plot their impulse response
> like so.
> 
> cheers
>   -- denis
> 
> """ plot map_coordinates( 1d spike )
> """
> 
> from __future__ import division
> import sys
> import numpy as np
> from scipy.ndimage import map_coordinates
> import pylab as pl
> 
> N = 10
> exec( "\n".join( sys.argv[1:] ))  # N= ...
> np.set_printoptions( 2, threshold=100, suppress=True )  # .2f
> 
> a = np.r_[ 5*[0], 1., 5*[0], 1,1, 5*[0], 5*[1] ]  # 0 1 1 0  -> 1.2
> na = len(a) - 1
> x = np.linspace( 0, na, na*N + 1 )
> print "a:", a.astype(int)
> 
> for order in (3,):
>     z = map_coordinates( a, [x], order=order )
>     print "z[%d] halfint:" % order, z[N//2::N]
>     pl.plot( x, z )
> 
> pl.show()
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
> 
> 

-- 
View this message in context: http://old.nabble.com/3D-interpolation-tp26919717p26954588.html
Sent from the Scipy-User mailing list archive at Nabble.com.




More information about the SciPy-User mailing list