interpolateScattered

PURPOSE ^

INTERPOLATE Convenience function providing a simple interphase to the

SYNOPSIS ^

function zi = interpolate(x, y, z, xi, yi, method, options)

DESCRIPTION ^

INTERPOLATE Convenience function providing a simple interphase to the
different interpolation methods in the Heightmap Interpolation Toolbox
 
 Input:
   - x, y, z: the known function values of the bivariate function f(x,y)=z
   - xi, yi: locations to interpolate
   - method: the method to use. Available:
               - 'Nearest': Nearest Neighbor.
               - 'Delaunay': Delaunay triangulation (linear interpolation).
               - 'Natural': Natural neighbors.
               - 'IDW': Inverse Distance Weighted.
               - 'Kriging': Kriging interpolation.
               - 'MLS': Moving Least Squares.
               - 'RBF.<rbf_type>': Radial Basis Functions.
               - 'QTPURBF.<rbf_type>': QuadTree Partition of Unity BRF.
       For the last two cases, you need to indicate in <rbf_type>
       the type of the Radial Basis Function to use. Available:
               - 'linear'
               - 'cubic'
               - 'quintic'
               - 'multiquadric'
               - 'thinplate'
               - 'green'
               - 'tensionspline'
               - 'regularizedspline'
               - 'gaussian'
               - 'wendland'
       For more information on each RBF, please check their
       individual documentation in their corresponding functions on
       the "rbf" folder of this toolbox.
   - options: Options data structure. Each algorithm has its own set of
       options that may be tunned according to the data. In case this
       structure is not provided, a set of default values will be
       generated using the hmitDefaultOptions function. The values
       returned by this function may not fit your data at all. We
       encourage the user to read the documentation of the individual
       methods in order to set the options properly. The parameters
       structure should follow that returned by the hmitDefaultOptions
       function, so a good way of setting parameters is to generate this
       structure using the hmitDefaultOptions function, and then change
       some of them as required. Note: 'Nearest', 'Delaunay' and 'Natural'
       methods do not require any parameters, so you can skip this parameter.
 
 Output:
   - zi: the interpolated z values

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function zi = interpolate(x, y, z, xi, yi, method, options)
0002 %INTERPOLATE Convenience function providing a simple interphase to the
0003 %different interpolation methods in the Heightmap Interpolation Toolbox
0004 %
0005 % Input:
0006 %   - x, y, z: the known function values of the bivariate function f(x,y)=z
0007 %   - xi, yi: locations to interpolate
0008 %   - method: the method to use. Available:
0009 %               - 'Nearest': Nearest Neighbor.
0010 %               - 'Delaunay': Delaunay triangulation (linear interpolation).
0011 %               - 'Natural': Natural neighbors.
0012 %               - 'IDW': Inverse Distance Weighted.
0013 %               - 'Kriging': Kriging interpolation.
0014 %               - 'MLS': Moving Least Squares.
0015 %               - 'RBF.<rbf_type>': Radial Basis Functions.
0016 %               - 'QTPURBF.<rbf_type>': QuadTree Partition of Unity BRF.
0017 %       For the last two cases, you need to indicate in <rbf_type>
0018 %       the type of the Radial Basis Function to use. Available:
0019 %               - 'linear'
0020 %               - 'cubic'
0021 %               - 'quintic'
0022 %               - 'multiquadric'
0023 %               - 'thinplate'
0024 %               - 'green'
0025 %               - 'tensionspline'
0026 %               - 'regularizedspline'
0027 %               - 'gaussian'
0028 %               - 'wendland'
0029 %       For more information on each RBF, please check their
0030 %       individual documentation in their corresponding functions on
0031 %       the "rbf" folder of this toolbox.
0032 %   - options: Options data structure. Each algorithm has its own set of
0033 %       options that may be tunned according to the data. In case this
0034 %       structure is not provided, a set of default values will be
0035 %       generated using the hmitDefaultOptions function. The values
0036 %       returned by this function may not fit your data at all. We
0037 %       encourage the user to read the documentation of the individual
0038 %       methods in order to set the options properly. The parameters
0039 %       structure should follow that returned by the hmitDefaultOptions
0040 %       function, so a good way of setting parameters is to generate this
0041 %       structure using the hmitDefaultOptions function, and then change
0042 %       some of them as required. Note: 'Nearest', 'Delaunay' and 'Natural'
0043 %       methods do not require any parameters, so you can skip this parameter.
0044 %
0045 % Output:
0046 %   - zi: the interpolated z values
0047 %
0048 
0049 % Parameters' check
0050 if nargin < 7 && ~strcmpi(method, 'Nearest') && ~strcmpi(method, 'Delaunay') && ~strcmpi(method, 'Natural')
0051     options = hmitDefaultOptions(x, y, z, xi, yi);
0052 end
0053 
0054 C = strsplit(method, '.');
0055 method = C{1};
0056 if numel(C) > 1
0057     rbfType = lower(C{2});
0058 end
0059 
0060 switch lower(method)
0061     case 'nearest'
0062         nearNeighInterp = NearestNeighborInterpolant(x, y, z);
0063         zi = nearNeighInterp.interpolate(xi, yi);
0064     case 'delaunay'
0065         dtInterp = DelaunayTINInterpolant(x, y, z);
0066         zi = dtInterp.interpolate(xi, yi);
0067     case 'natural'
0068         naturNeighInterp = NaturalNeighborsInterpolant(x, y, z);
0069         zi = naturNeighInterp.interpolate(xi, yi);
0070     case 'idw'
0071         idwInterp = IDWInterpolant(x, y, z, 'DistanceType', options.DistanceType, ...
0072                                         'SearchType', options.IDW.SearchType, ...
0073                                         'k', options.IDW.K, ...
0074                                         'Radius', options.IDW.Radius, ...
0075                                         'Power', options.IDW.Power);
0076         zi = idwInterp.interpolate(xi, yi);                            
0077     case 'kriging'
0078         % Create the experimental variogram from the samples
0079         vg = Variogram(x, y, z, 'model', options.Kriging.Variogram.Type, ...
0080                                 'DistanceType', options.DistanceType, ...
0081                                 'NumBins', options.Kriging.Variogram.NumSamples, ...
0082                                 'OptimNugget', options.Kriging.Variogram.OptimNugget);
0083 
0084         % Use it in the Kriging
0085         krigInterp = KrigingInterpolant(x, y, z, vg, 'DistanceType', options.DistanceType, ...
0086                                                      'PolynomialDegree', options.Kriging.PolynomialDegree, ...
0087                                                      'Smooth', options.Kriging.Smooth, ...
0088                                                      'Regularization', options.Kriging.Regularization);
0089         zi = krigInterp.interpolate(xi, yi);
0090     case 'mls'
0091         mlsInterp = MLSInterpolant(x, y, z, 'DistanceType', options.DistanceType, ...
0092                                             'PolynomialDegree', options.MLS.PolynomialDegree, ...
0093                                             'RBF', options.MLS.RBF, ...
0094                                             'RBFEpsilon', options.MLS.RBFEpsilon, ...
0095                                             'MinSamples', options.MLS.MinSamples);
0096         zi = mlsInterp.interpolate(xi, yi);
0097     case 'rbf'
0098         rbfInterp = RBFInterpolant(x, y, z, 'DistanceType', options.DistanceType, ...
0099                                             'PolynomialDegree', options.RBF.(rbfType).PolynomialDegree, ...
0100                                             'RBF', rbfType, ...
0101                                             'RBFEpsilon', options.RBF.(rbfType).RBFEpsilon, ... 
0102                                             'Smooth', options.RBF.(rbfType).Smooth, ...
0103                                             'Regularization', options.RBF.(rbfType).Regularization);
0104         zi = rbfInterp.interpolate(xi, yi);          
0105     case 'qtpurbf'
0106         rbfInterp = QuadTreePURBFInterpolant(x, y, z, 'MinPointsInCell', options.PURBF.MinPointsInCell, ...
0107                                                       'Overlap', options.PURBF.Overlap, ...
0108                                                       'Domain', options.PURBF.Domain, ...
0109                                                       'DistanceType', options.DistanceType, ...
0110                                                       'PolynomialDegree', options.RBF.(rbfType).PolynomialDegree, ...
0111                                                       'RBF', rbfType, ...
0112                                                       'RBFEpsilon', options.RBF.(rbfType).RBFEpsilon, ... 
0113                                                       'Smooth', options.RBF.(rbfType).Smooth, ...
0114                                                       'Regularization', options.RBF.(rbfType).Regularization);
0115         zi = rbfInterp.interpolate(xi, yi);          
0116     otherwise
0117         error('Unknown interpolation method');
0118 end
0119 
0120 end

Generated on Thu 10-Dec-2020 17:34:27 by m2html © 2005