1vpSetClassifierTable(3) Library Functions Manual vpSetClassifierTable(3)
2
3
4
6 vpSetClassifierTable - specify an opacity transfer function
7
9 #include <volpack.h>
10
11 vpResult
12 vpSetClassifierTable(vpc, param_num, param_field, table, table_size)
13 vpContext *vpc;
14 int param_num, param_field;
15 float *table;
16 int table_size;
17
19 vpc VolPack context from vpCreateContext.
20
21 param_num
22 Parameter number identifying one parameter of the opacity trans‐
23 fer function.
24
25 param_field
26 Field number identifying a voxel field that contains the parame‐
27 ter.
28
29 table Lookup table that defines the mapping from the voxel field value
30 to the opacity.
31
32 table_size
33 Size of table in bytes.
34
36 vpSetClassifierTable is used to specify lookup tables that define an
37 opacity transfer function. The opacity transfer function must be of
38 the form: opacity = f0(param0) * f1(param1) * ... * fN(paramN) where
39 each of the factors is a function of one voxel field (see below for
40 implementing more general classification models). vpSetClassifierTable
41 must be called once for each factor to specify a lookup table that
42 defines the factor. After the function has been specified, opacities
43 are computed by calling one of the classification functions: vpClassi‐
44 fyScalars, vpClassifyVolume, or vpClassifyScanline. To classify a
45 voxel, these functions use the values in the fields of the voxel as
46 indexes into the opacity transfer function tables, retrieve one value
47 from each table, and multiply the values together to compute the opac‐
48 ity for the voxel. The opacity should be a number in the range
49 0.0-1.0, so normally each table contains numbers that are also in this
50 range.
51
52 The parameters of the opacity transfer function are numbered from zero,
53 and the total number of parameters must be specified using vpSetVoxel‐
54 Size before calling vpSetClassifierTable. The number of parameters is
55 independent of the number of voxel fields: some fields may not be used
56 as parameters, and one field could be used multiple times (although
57 this is inefficient since all of the tables indexed by the same parame‐
58 ter could be merged into one table).
59
60 Each table should be a 1D array of numbers with one entry for each pos‐
61 sible value of the corresponding voxel field. The voxel field must
62 contain an unsigned integer quantity. Normally each table would be
63 declared: float table[MAX_FIELD_VALUE + 1]; where MAX_FIELD_VALUE is
64 the maximum possible value in the voxel field as specified with
65 vpSetVoxelField. The table may also be dynamically allocated. Note
66 that VolPack will never free the table, even if the VolPack context is
67 destroyed with vpDestroyContext, so the application is responsible for
68 freeing the memory when appropriate. The values in the table may be
69 initialized or modified at any time before or after calling vpSetClas‐
70 sifierTable, but before calling one of the classification routines.
71 See the function vpRamp for a convenient way to initialize tables with
72 piece-wise linear ramps.
73
74 Classification functions that are not expressible in the form above can
75 be handled as follows. First, write your own routine that computes the
76 opacity for each voxel. Next, quantize the opacities using somewhere
77 between 8 and 16 bits per voxel, and store the quantized values in one
78 field of each voxel. Finally, define an opacity transfer function ta‐
79 ble that maps the quantized opacities into a floating point number in
80 the range 0.0-1.0 and use the table to define a single-parameter opac‐
81 ity transfer function by calling vpSetClassifierTable.
82
83 The minimum opacity threshold should be set at the same time as the
84 opacity transfer function. See the VP_MIN_VOXEL_OPACITY argument to
85 vpSetd.
86
88 The current classification function parameters can be retrieved with
89 the following state variable codes (see vpGeti(3)): VP_CLAS‐
90 SIFY_FIELD_COUNT, VP_CLASSIFY_FIELDS, VP_CLASSIFY_TABLES, VP_CLAS‐
91 SIFY_TABLE_SIZES, VP_MIN_VOXEL_OPACITY
92
94 The normal return value is VP_OK. The following error return value is
95 possible:
96
97 VPERROR_BAD_VALUE
98 Either param_num or field_num is out of range.
99
101 VolPack(3), vpCreateContext(3), vpClassifyScanline(3), vpClassi‐
102 fyScalars(3), vpClassifyVolume(3), vpRamp(3)
103
104
105
106VolPack vpSetClassifierTable(3)