| 1 | |
| 2 | /* |
| 3 | * Argyll Color Management System |
| 4 | * |
| 5 | * Scattered Data Interpolation with multilevel B-splines library. |
| 6 | * This can be used by rspl, or independently by any other routine. |
| 7 | * |
| 8 | * Author: Graeme W. Gill |
| 9 | * Date: 2001/1/1 |
| 10 | * |
| 11 | * Copyright 2000 - 2001 Graeme W. Gill |
| 12 | * All rights reserved. |
| 13 | * |
| 14 | * This material is licenced under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 :- |
| 15 | * see the License.txt file for licencing details. |
| 16 | */ |
| 17 | |
| 18 | /* |
| 19 | * This is from the paper |
| 20 | * "Scattered Data Interpolation with Multilevel B-Splines" |
| 21 | * by Seungyong Lee, George Wolberg and Sung Yong Shin, |
| 22 | * IEEE Transactions on Visualisation and Computer Graphics |
| 23 | * Vol. 3, No. 3, July-September 1997, pp 228. |
| 24 | */ |
| 25 | |
| 26 | #include "rspl.h" /* Define some common elements */ |
| 27 | |
| 28 | /* Neighborhood latice cache data */ |
| 29 | typedef struct { |
| 30 | int c[MXDI]; /* Coordinate */ |
| 31 | int xo; /* Offset into slbs latice */ |
| 32 | double w; /* B-spline basis weight */ |
| 33 | } neigh; |
| 34 | |
| 35 | /* Structure that represents a resolution level of B-splines */ |
| 36 | struct _slbs { |
| 37 | struct _mlbs *p; /* Parent structure */ |
| 38 | int res; /* Basic resolution */ |
| 39 | int coi[MXDI]; /* Double increment for each input dimension into latice */ |
| 40 | double *lat; /* Control latice, extending from +/- 1 from 0..res-1 */ |
| 41 | double *_lat; /* Allocation base of lat */ |
| 42 | int lsize, loff; /* Number of doubles in _lat, offset of lat from _lat */ |
| 43 | double w[MXDI]; /* Input data cell width */ |
| 44 | neigh *n; /* Neighborhood latice cache */ |
| 45 | int nsize; /* Number of n entries */ |
| 46 | }; typedef struct _slbs slbs; |
| 47 | |
| 48 | /* Structure that represents the whole scattered interpolation state */ |
| 49 | struct _mlbs { |
| 50 | int di; /* Input dimensions */ |
| 51 | int fdi; /* Output dimensions */ |
| 52 | int tres; /* Target resolution */ |
| 53 | double smf; /* Smoothing factor */ |
| 54 | int npts; /* Number of data points */ |
| 55 | dpnts *pts; /* Coordinate points and weights (valid while creating) */ |
| 56 | double l[MXDI], h[MXDI]; /* Input data range, cell width */ |
| 57 | slbs *s; /* Current B-spline latice */ |
| 58 | |
| 59 | int (*lookup)(struct _mlbs *p, co *c); |
| 60 | |
| 61 | void (*del)(struct _mlbs *p); |
| 62 | |
| 63 | }; typedef struct _mlbs mlbs; |
| 64 | |
| 65 | |
| 66 | /* Create a new empty mlbs */ |
| 67 | mlbs *new_mlbs( |
| 68 | int di, /* Input dimensionality */ |
| 69 | int fdi, /* Output dimesionality */ |
| 70 | int res, /* Minimum final resolution */ |
| 71 | dpnts *pts, /* scattered data points and weights */ |
| 72 | int npts, /* number of scattered data points */ |
| 73 | double *l, /* Input data range, low (May be NULL) */ |
| 74 | double *h, /* Input data range, high (May be NULL) */ |
| 75 | double smf /* Smoothing factor */ |
| 76 | ); |
| 77 |