15 |
|
#define NI2DSMF 0.42f /* minimal smoothing factor */ |
16 |
|
|
17 |
|
#define NI2DIR (2*4) /* # interpolation directions */ |
18 |
+ |
#define NI2DIM 16 /* size of black flag array */ |
19 |
|
|
20 |
|
/* Data structure for interpolant */ |
21 |
|
typedef struct { |
22 |
|
int ns; /* number of sample positions */ |
23 |
|
float dmin; /* minimum diameter (default=1) */ |
24 |
|
float smf; /* smoothing factor (def=NI2DSMF) */ |
25 |
< |
unsigned short (*da)[NI2DIR]; /* anisotropic distances (private) */ |
25 |
> |
float smin[2]; /* sample minima */ |
26 |
> |
float smul[2]; /* NI2DIM/(smax-smin) */ |
27 |
> |
float grid2; /* twice grid diameter squared */ |
28 |
> |
struct interp2_samp { |
29 |
> |
unsigned short dia[NI2DIR]; |
30 |
> |
unsigned short blkflg[NI2DIM]; |
31 |
> |
} *da; /* direction array (private) */ |
32 |
|
float spt[1][2]; /* sample positions (extends struct) */ |
33 |
|
} INTERP2; |
34 |
|
|
38 |
|
/* Resize interpolation array (caller must assign any new values) */ |
39 |
|
extern INTERP2 *interp2_realloc(INTERP2 *ip, int nsamps); |
40 |
|
|
41 |
+ |
/* Set minimum distance under which samples will start to merge */ |
42 |
+ |
extern void interp2_spacing(INTERP2 *ip, double mind); |
43 |
+ |
|
44 |
+ |
/* Modify smoothing parameter by the given factor */ |
45 |
+ |
extern void interp2_smooth(INTERP2 *ip, double sf); |
46 |
+ |
|
47 |
|
/* Assign full set of normalized weights to interpolate the given location */ |
48 |
|
extern int interp2_weights(float wtv[], INTERP2 *ip, double x, double y); |
49 |
|
|
56 |
|
/* (Re)compute anisotropic basis function interpolant (normally automatic) */ |
57 |
|
extern int interp2_analyze(INTERP2 *ip); |
58 |
|
|
59 |
+ |
/* Compute unnormalized weight for a position relative to a sample */ |
60 |
+ |
double interp2_wti(INTERP2 *ip, const int i, double x, double y); |
61 |
+ |
|
62 |
|
/*************************************************************** |
63 |
|
* Typical use is to allocate an INTERP2 struct and assign the |
64 |
|
* spt[] array with the ordered sample locations in x & y. (The |
68 |
|
* vector for all the samples, or interp2_topsamp() is called to |
69 |
|
* get the most important N samples for the specified location. |
70 |
|
* The weights (and indexes in the case of interp2_topsamp) |
71 |
< |
* are then used as coefficients for corresponding sample values |
72 |
< |
* in a vector sum together that interpolates the function at that |
73 |
< |
* location. Between the initial allocation call and the first |
74 |
< |
* weight evaluation, the dmin member may be adjusted to |
75 |
< |
* the distance under which samples will start to merge. If this |
76 |
< |
* parameter is later changed, interp2_analyze() should be called |
77 |
< |
* to recompute the interpolant. |
78 |
< |
* The smf member sets the smoothing factor for interpolation. |
79 |
< |
* The default setting of NI2DSMF produces near-optimal |
80 |
< |
* interpolation when well-separated sample values are known |
81 |
< |
* precisely. If a greater degree of mixing is desired, this |
82 |
< |
* paremter may be increased and it will affect the next call |
83 |
< |
* to interp2_weights() or interp2_topsamp(). |
71 |
> |
* are then used as coefficients for corresponding sample |
72 |
> |
* values in a vector sum that interpolates the function at |
73 |
> |
* that location. |
74 |
> |
* The minimum distance between sample positions defaults to 1.0. |
75 |
> |
* Values spaced closer than this will be merged/averaged. |
76 |
> |
* The interp2_spacing() call may be used to alter this distance, |
77 |
> |
* causing the interpolant to be recalculated during the |
78 |
> |
* next call to the sampling functions. |
79 |
> |
* The default smoothing factor NI2DSMF provides near-optimal |
80 |
> |
* interpolation when well-separated values are known |
81 |
> |
* precisely. Increase this setting by a factor > 1 |
82 |
> |
* with the interp2_smooth() call if greater mixing is desired. |
83 |
> |
* A call of interp2_smooth(ip,0) resets to the minimum |
84 |
> |
* default. It is not possible to "sharpen" the data. |
85 |
|
**************************************************************/ |
86 |
|
|
87 |
|
#ifdef __cplusplus |