SciPy N-D interpolation functions
See original GitHub issueFrom @jakirkham on May 16, 2017 18:35
The list of functions below are what that this library intends to support with Dask Arrays. These all come from SciPy. In particular they come from scipy.ndimage.interpolation
. The intent is to emulate their behavior with Dask Arrays as wrapping them is not likely to work. Will also include tests to verify these retain the behavior that the SciPy functions ordinarily have.
- affine_transform
- geometric_transform
- map_coordinates
- rotate
- shift
- spline_filter
- spline_filter1d
- zoom
Copied from original issue: dask-image/dask-ndinterp#3
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Interpolation (scipy.interpolate) — SciPy v1.9.3 Manual
As listed below, this sub-package contains spline functions and classes, 1-D and multidimensional (univariate and multivariate) interpolation classes, ...
Read more >Interpolation (scipy.interpolate) — SciPy v1.9.3 Manual
A class representing an interpolant ( interp1d ) in 1-D, offering several interpolation methods. · Convenience function griddata offering a simple interface to ......
Read more >scipy.interpolate.LinearNDInterpolator — SciPy v1.9.3 Manual
The interpolant is constructed by triangulating the input data with Qhull [1], and on each triangle performing linear barycentric interpolation. References.
Read more >scipy.interpolate.interp1d — SciPy v1.9.3 Manual
. This class returns a function whose call method uses interpolation to find the value of new points. A 1-D array of real...
Read more >scipy.interpolate.interpn — SciPy v1.9.3 Manual
Piecewise linear interpolant on unstructured data in N dimensions ... interpolation on grids with equal spacing (suitable for e.g., N-D image resampling).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @m-albert, this is interesting! I had been hoping to look at this at some point for GPU applications where memory limits can sometimes be an issue, so it is great to see this here.
In regards to the amount to pad the blocks, it is a little bit tricky, but I will explain what I think is the solution below. The first consideration are the samples that fall within the footprint of the spline kernel. I see you currently extend by 2 samples at each boundary to attempt to account for that which should be enough for all but order 5 where the filter is width 6.
Specifically, the spline interpolation kernel has width
order + 1
with starting and (inclusive) ending samples used to interpolate a coordinate, x, given by the following function adapted from the C sourceSo even for order 5, interpolating a value at location 0.2 for example would involve weights applied to samples from coordinate locations [-2, -1, 0, 1, 2, 3].
However, there is another, possibly more important consideration in the case of
order > 1
. For those cases, there is also a spline prefiltering step that involves application of an infinite impulse response (IIR) filter. In short this means there will be boundary errors in the prefiltering that decay with increasing distance from the block boundaries and may be noticeable for 10 or more samples. Rather than use a larger padding, the optimal workaround for that should be to first perform prefiltering independently viandimage.spline_filter
and then applyaffine_transform
with the argumentprefilter=False
.spline_filter
should be pretty trivial to split up for dask and avoid artifacts because it is separable across axes (i.e.spline_filter
just appliesspline_filter1d
along each axis in turn). Fordask-image
, when filtering along axisn
we should set it to have only 1 chunk on that axis to avoid boundary artifacts, but multiple chunks can be used on any of the other axes. Once you have the prefiltered result, proceed as proposed here, but usingprefilter=False
.Hey @jakirkham @GenevieveBuckley @wtbarnes @jni,
I wrote a function that implements
ndimage.affine_transform
for dask arrays and takes care of what @jni mentions, that in general input and output blocks are not aligned.Here’s a gist containing the code with example usage and timing.
Would be cool to include this functionality in
dask-image
!