| 1 |
|
/* RCSid $Id$ */ |
| 2 |
|
/* |
| 3 |
< |
* Header for interpolation of anisotropic values on 2-D plane. |
| 3 |
> |
* Header for interpolation of anisotropic samples on 2-D plane. |
| 4 |
|
* |
| 5 |
|
* G.Ward Feb 2013 |
| 6 |
|
*/ |
| 12 |
|
extern "C" { |
| 13 |
|
#endif |
| 14 |
|
|
| 15 |
< |
#define NI2DSMF 0.42f /* minimal smoothing radius */ |
| 15 |
> |
#define NI2DSMF 0.42f /* minimal smoothing factor */ |
| 16 |
|
|
| 17 |
|
#define NI2DIR (2*4) /* # interpolation directions */ |
| 18 |
|
|
| 19 |
|
/* Data structure for interpolant */ |
| 20 |
|
typedef struct { |
| 21 |
|
int ns; /* number of sample positions */ |
| 22 |
< |
float rmin; /* minimum valid radius (default=.5) */ |
| 22 |
> |
float dmin; /* minimum diameter (default=1) */ |
| 23 |
|
float smf; /* smoothing factor (def=NI2DSMF) */ |
| 24 |
< |
unsigned short (*ra)[NI2DIR]; /* anisotropic radii (private) */ |
| 24 |
> |
unsigned short (*da)[NI2DIR]; /* anisotropic distances (private) */ |
| 25 |
|
float spt[1][2]; /* sample positions (extends struct) */ |
| 26 |
|
} INTERP2; |
| 27 |
|
|
| 31 |
|
/* Resize interpolation array (caller must assign any new values) */ |
| 32 |
|
extern INTERP2 *interp2_realloc(INTERP2 *ip, int nsamps); |
| 33 |
|
|
| 34 |
+ |
/* Set minimum distance under which samples will start to merge */ |
| 35 |
+ |
extern void interp2_spacing(INTERP2 *ip, double mind); |
| 36 |
+ |
|
| 37 |
+ |
/* Modify smoothing parameter by the given factor */ |
| 38 |
+ |
extern void interp2_smooth(INTERP2 *ip, double sf); |
| 39 |
+ |
|
| 40 |
|
/* Assign full set of normalized weights to interpolate the given location */ |
| 41 |
|
extern int interp2_weights(float wtv[], INTERP2 *ip, double x, double y); |
| 42 |
|
|
| 49 |
|
/* (Re)compute anisotropic basis function interpolant (normally automatic) */ |
| 50 |
|
extern int interp2_analyze(INTERP2 *ip); |
| 51 |
|
|
| 52 |
+ |
/*************************************************************** |
| 53 |
+ |
* Typical use is to allocate an INTERP2 struct and assign the |
| 54 |
+ |
* spt[] array with the ordered sample locations in x & y. (The |
| 55 |
+ |
* actual orientation of the axes is not important so long as |
| 56 |
+ |
* the application is consistent.) During interpolation, either |
| 57 |
+ |
* interp2_weights() is called to obtain a normalized weighting |
| 58 |
+ |
* vector for all the samples, or interp2_topsamp() is called to |
| 59 |
+ |
* get the most important N samples for the specified location. |
| 60 |
+ |
* The weights (and indexes in the case of interp2_topsamp) |
| 61 |
+ |
* are then used as coefficients for corresponding sample values |
| 62 |
+ |
* in a vector sum that interpolates the function at that |
| 63 |
+ |
* location. |
| 64 |
+ |
* The minimum distance between sample positions defaults to 1.0. |
| 65 |
+ |
* Values spaced closer than this will be merged (averaged). The |
| 66 |
+ |
* interp2_spacing() call may be used to alter this member, |
| 67 |
+ |
* causing the interpolant to be recalculated during the |
| 68 |
+ |
* next call to either of the sampling functions. |
| 69 |
+ |
* The default smoothing factor NI2DSMF provides near-optimal |
| 70 |
+ |
* interpolation when well-separated values are known |
| 71 |
+ |
* precisely. Increase this setting by a factor > 1.0 |
| 72 |
+ |
* with the interp2_smooth() call if greater mixing is desired. |
| 73 |
+ |
* A call of interp2_smooth(ip,0.0) resets to the minimum |
| 74 |
+ |
* default. It is not possible to "sharpen" the data. |
| 75 |
+ |
**************************************************************/ |
| 76 |
+ |
|
| 77 |
|
#ifdef __cplusplus |
| 78 |
|
} |
| 79 |
|
#endif |