User Tools

Site Tools


flexinterpn_method

flexinterpn_method

This is a proxy function for flexinterpn. It only handles some standard kernels as well as 2D to 3D data conversion for rotation.

Motivation

While the flexinterpn function allows very flexible interpolation of data, it would be too cumbersome to expect that every user (including myself) will create a suitable kernel window over and over again whenever data is to be interpolated.

The flexinterpn_method function creates a persistent variable and stores some of the more standard kernel windows in a 4096-sampling resolution (enough to allow the linear interpolation internally applied by flexinterpn to yield high-quality results, tested with the Lanczos8 window mentioned at the interpolation quality test page (external link).

Function reference ('help flexinterpn_method')

  flexinterpn_method  - call flexinterpn with one of the typical methods
 
  FORMAT:       [idata, k] = flexinterpn_method(data, cr [, [opts], method])
 
  Input fields:
 
        data        N-d data (up to 4 dims supported)
        cr          CxD coordinates or 4xD range
        opts        hold (and tranformation matrix)
        method      either of: 
                    'cubic', 'lanczos2' 'lanczos3', {'linear'},
                    'nearest', 'poly3', 'spline2', 'spline3'
 
  Output fields:
 
        idata       interpolated data as from flexinterpn
        k           kernel passed to flexinterpn (empty for linear)
 
  Note: the range notation of cr must contain Infs in the first row
        of values, the rest is parsed as row2:row3:row4 for each dim.
 
  Note: for methods other than nearest and linear, the value range of
        the input can be exceeded!

Arguments

The first two arguments, data and cr are identical to the use of flexinterpn with one notable exception: 2D image data can be passed into the function which will then be shifted into the third dimension to allow the quaternion matrix to be used (the rotation must be defined around the 1st dimension!)

opts

Here, neither, the first, or both of the last two arguments of flexinterpn can be given (so, possibly, neither hold and qtrf, only hold, or both hold and qtrf).

method

The following methods (kernel shapes) are supported:

  • cubic (hermite cubic spline, see bottom of the interpolation test page for formula)
  • lanczos2/3 (same information source)
  • linear (standard kernel, [0; 1; 0] with a sampling kernsize of 1)
  • nearest (this is only an approximation! for very few interpolation coordinate, the value will yet be a linear interpolation, better: use data(round(coords)))
  • poly3/spline2/spline3 (additional methods mentioned on that page, not used by other functions of the toolbox)

Usage

There are two main uses of this function:

  • actual data interpolation (passing on data to flexinterpn):
    flexinterpn_method_data.m
    % passing data from flexinterpn_method -> flexinterpn
    resampled = flexinterpn_method(data, range, 'cubic');<code>
      * generating/requesting a suitable kernel that is then manually passed to [[flexinterpn]]: <code matlab flexinterpn_method_kernelonly.m>% get cubic interpolation kernel
    [null, k] = flexinterpn_method(1, 1, 'cubic');
flexinterpn_method.txt · Last modified: 2010/06/21 07:23 by jochen