[SciPy-user] Thin plates for a 3D deformation field
Sat Oct 27 21:39:32 CDT 2007
Matthieu Brucher wrote:
> I wondered if someone knew of a package that allows the interpolation of
> a 3D deformation field with thin plates (or in fact with anything) based
> on a list of points and their associated deformation field.
> If only 2D deformation field is supported by a package, I'll go for it
> too ;)
Another alternative is to use the natural-neighbor interpolation that I coded
up. I've moved it to its own scikit for easier installation.
At the moment, I only support doing one dimension at a time, but that can be
easily worked around. Let's say you have your deformation field separated into 3
shape-(n,) arrays dx, dy, and dz and you have spatial coordinates in shape-(n,)
arrays x and y.
from scikits.delaunay import Triangulation
t = Triangulation(x, y)
dxinterp = t.nn_interpolator(dx)
dyinterp = t.nn_interpolator(dy)
dzinterp = t.nn_interpolator(dz)
# Use nn_extrapolator if you want to find values outside of the convex hull of
# the input points.
If your interpolating points are on a grid, the easiest way to get the
interpolated values is by "fake" slicing along the lines of numpy.mgrid.
dx2 = dxinterp[0:1:101j, 0:2:201j]
That interpolates the dx deformation across a grid going from 0 to 2 (inclusive)
at a step of 0.01 in the X direction and 0 to 1 (inclusive) at a step of 0.01 in
the Y direction (yes, the Y coordinate comes first; I'm not much happy with that
either, but it seemed the most consistent with the way indexing "looks"). That
should be reasonably fast; I've optimized grid-structured interpolating point sets.
Let me know if you try this and anything you think can or should be improved
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the SciPy-user