vpResample(3)

πŸ’– vpResample(3) πŸ’–

okay bestie, welcome to the volpack library manual, section 3 (library functions, the fun ones) πŸ’… today we're talking about vpResample, vpResample2D, and vpResample3D β€” the trio that resamples an array for you. no cap, this is the glow-up-your-volume-data page. let's get into it ✨


🌸 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;

πŸŽ€ ARGUMENTS πŸŽ€

  • vpc β€” the VolPack context you got from vpCreateContext. your main character context fr.
  • num_dimens β€” how many dimensions the input and output arrays have. like, the dimensionality count.
  • src_dimens β€” array holding the dimensions of the input array.
  • dst_dimens β€” array holding the dimensions of the output array.
  • src_strides β€” array holding the strides for each dimension of the input array.
  • dst_strides β€” array holding the strides for each dimension of the output array.
  • element_type β€” constant that says what data type the array elements are (VP_UCHAR, VP_USHORT, VP_FLOAT).
  • src_array β€” the input array, aka where your input data lives.
  • dst_array β€” the output array, aka where the result data goes. it's giving ✨results✨.
  • 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 β€” constant picking one of the predefined filters (VP_BOX_FILTER, VP_LINEAR_FILTER, VP_GAUSSIAN_FILTER, VP_BSPLINE_FILTER, VP_MITCHELL_FILTER). pick your fave πŸ’…

πŸ’œ DESCRIPTION πŸ’œ

so vpResample resamples an array onto a new grid at a different resolution. literally that's its whole thing. you can use it to scale up or decimate an array of volume data, for instance. you can specify an arbitrary separable space-invariant resampling filter via a lookup table that contains filter weights. the input array can have an arbitrary number of dimensions, but here's the catch bestie: on each call to vpResample, only one dimension of the array gets resampled. so if you wanna scale all the dimensions, you call the routine once for each dimension. one at a time, no skipping. and no, transformations other than scales (like rotations and shears) are not supported by these routines β€” don't even try it πŸ™ˆ

then there's vpResample2D and vpResample3D, which give you a simpler (but less flexible) interface to vpResample. they take an input array with its dimensions, an output array with its dimensions, and a constant specifying a filter. the input array gets resampled once for each dimension and then stored in the output array. and the best part? these two routines automatically create a filter weight table and arrays for temporary results. so convenient, they ate πŸ“

the rest of this man page is all about vpResample. the vpc argument is a VolPack context that contains a description of the resampling filter. use vpSetFilter to define the filter, iykyk. also important: the volume data and rendering parameters currently stored in the context are not affected by calls to vpResample. your vibe stays intact, no cap.

the remaining 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's what num_dimens specifies. the sizes of the dimensions come from src_dimens and dst_dimens, which are 1D arrays with num_dimens elements in each array. src_dimens[0] is the size of the input dimension to be resampled. dst_dimens[0] is the size of the output dimension after resampling, so the scale factor is dst_dimens[0] / src_dimens[0]. the remaining elements of src_dimens give the sizes of the other input array dimensions in any order (although some orderings result in faster execution due to lower memory overhead β€” so like, order matters for speed, lowkey). the other output array dimensions are ignored (although they should be the same as the corresponding input array dimensions, since only one dimension is resampled). ignored but should match, it's giving "technically optional but be normal about it" 😭

the src_strides and dst_stride arguments are 1D arrays that contain 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.

the element_type argument specifies the data type of each element of the input and output data arrays. 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. point at the start and let it cook πŸ”₯


πŸ’€ ERRORS πŸ’€

the normal return value is VP_OK. bestie behavior.

the following error return values are possible:

  • VPERROR_BAD_SIZE β€” no filter weight table has been specified. oops, you forgot to define the filter. go call vpSetFilter 🫢

🌈 SEE ALSO 🌈

VolPack(3), vpSetFilter(3)


and that's the whole page, bestie πŸŽ€ this was the VolPack manual, page vpResample(3) β€” go forth and resample responsibly, you absolute icon πŸ‘‘πŸ’–

πŸ“¦ where this page comes from