vpResample(3)
π vpResample π
okay bestie, this is a page from the Library Functions Manual β three whole functions that resample an array, and we're gonna get into all of it. no skimming, no skipping, we're doing the whole thing. π
β¨ NAME β¨
vpResample, vpResample2D, vpResample3D β resample an array π¦
β¨ SYNOPSIS β¨
#include <volpack.h>
vpResult
vpResample(vpc, num_dimens, src_dimens, dst_dimens, src_strides,
dst_strides, element_type, src_array, dst_array)
vpContext *vpc;
int num_dimens;
int *src_dimens, *dst_dimens;
int *src_strides, *dst_strides;
int element_type;
void *src_array, *dst_array;
vpResult
vpResample2D(src_array, src_x, src_y, dst_array, dst_x, dst_y,
element_type, filter_type)
void *src_array;
int src_x, src_y;
void *dst_array;
int dst_x, dst_y;
int element_type;
int filter_type;
vpResult
vpResample3D(src_array, src_x, src_y, src_z, dst_array, dst_x, dst_y,
dst_z, element_type, filter_type)
void *src_array;
int src_x, src_y, src_z;
void *dst_array;
int dst_x, dst_y, dst_z;
int element_type;
int filter_type;
like. look at that. three functions, all sitting there, all ready to resize ur array. π
π«Ά ARGUMENTS π«Ά
vpcβ the VolPack context u got fromvpCreateContext. ur whole setup lives in here, periodt.num_dimensβ how many dimensions the input and output arrays have. they gotta match, no cap.src_dimensβ an array holding the dimensions of the input array.dst_dimensβ an array holding the dimensions of the output array.src_stridesβ an array with the stride for each dimension of the input array.dst_stridesβ an array with the stride for each dimension of the output array.element_typeβ a constant saying what data type the array elements are:VP_UCHAR,VP_USHORT, orVP_FLOAT.src_arrayβ the input array, holding the input data.dst_arrayβ the output array, where the result data goes. πsrc_x,src_y,src_zβ the dimensions of the input array.dst_x,dst_y,dst_zβ the dimensions of the result array.filter_typeβ a constant picking one of the predefined filters:VP_BOX_FILTER,VP_LINEAR_FILTER,VP_GAUSSIAN_FILTER,VP_BSPLINE_FILTER,VP_MITCHELL_FILTER.
π DESCRIPTION π
so vpResample resamples an array onto a new grid with a different resolution. it can scale an array of volume data up, or decimate it down, whatever u need. u can hand it an arbitrary separable space-invariant resampling filter through a lookup table that holds the filter weights. β¨
the input array can have literally any number of dimensions, BUT β and this is the plot twist β on each call to vpResample, only one dimension gets resampled. so if u wanna scale all the dimensions, u call the routine once per dimension. it's giving one-at-a-time energy, and we respect it. π§
and listen: transformations other than scales, like rotations and shears? not supported by these routines. that's just not their thing.
πΈ the 2D and 3D besties πΈ
vpResample2D and vpResample3D are the simpler (but less flexible) interface to vpResample. they take an input array plus its dimensions, an output array plus its dimensions, and a constant naming a filter. the input array gets resampled once for each dimension, then stored in the output array. these two also automatically create a filter weight table and arrays for temporary results, so they're doing a lil extra work behind the scenes for u. π
π the rest is all about vpResample π
the rest of this page describes vpResample. the vpc argument is a VolPack context that contains a description of the resampling filter β use vpSetFilter to define that filter. important: the volume data and rendering parameters currently stored in the context are not affected by calls to vpResample. ur context's stuff stays exactly where it is. π«Ά
the other arguments to vpResample describe the size and layout of the input and output arrays. the two arrays have to have the same number of dimensions, and that number is num_dimens. the sizes of the dimensions come from src_dimens and dst_dimens, which are 1D arrays with num_dimens elements each.
src_dimens[0]is the size of the input dimension that's getting resampled.dst_dimens[0]is the size of the output dimension after resampling β so the scale factor isdst_dimens[0] / src_dimens[0]. π₯
the remaining elements of src_dimens give the sizes of the other input array dimensions, in any order (though heads up, some orderings run faster because of lower memory overhead β iykyk). the other output array dimensions are ignored, though they should really be the same as the corresponding input array dimensions, since only one dimension is being resampled. π
the src_strides and dst_stride arguments are 1D arrays that hold a stride in bytes for each dimension of the input and output arrays, stored in the same order as the dimension sizes in src_dimens.
β element_type, the data type era β
the element_type argument says what the data type of each element of the input and output data arrays is. the supported types are:
VP_UCHARβ unsigned character, 1 byte per element.VP_USHORTβ unsigned short, 2 bytes per element.VP_FLOATβ single-precision floating point, 4 bytes per element.
and finally, the last two arguments to vpResample are pointers to the first elements of the input and output arrays. that's it, that's the whole vibe check. π
π ERRORS π
the normal return value is VP_OK. the following error return values are possible:
VPERROR_BAD_SIZEβ no filter weight table has been specified. π
not me forgetting the filter weight table... bestie. pls. specify it.
π¦ SEE ALSO π¦
and that's the whole page, bestie!! this one's from VolPack, and it's the vpResample(3) era β go forth and resample responsibly πβ¨ππ¦πΈπ
π¦ where this page comes from
- fedora 43: volpack 1.0c7-35.fc43 Β· BSD-3-Clause
- fedora 43: volpack 1.0c7-35.fc43 Β· BSD-3-Clause
- fedora 44: volpack 1.0c7-36.fc44 Β· BSD-3-Clause
- fedora 44: volpack 1.0c7-36.fc44 Β· BSD-3-Clause
- Copyright (c) 1995-2008, Stanford University
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms