linumpy.gpu.interpolation#

GPU-accelerated interpolation and resampling operations for linumpy.

Provides GPU versions of image resampling, affine transforms, and coordinate mapping operations.

Functions#

affine_transform(image, matrix[, output_shape, order, ...])

GPU-accelerated affine transformation.

map_coordinates(image, coordinates[, order, use_gpu])

GPU-accelerated coordinate mapping (general interpolation).

resize(image, output_shape[, order, anti_aliasing, ...])

GPU-accelerated image resize.

apply_displacement_field(image, displacement_field[, ...])

Apply a displacement field to warp an image.

resample_volume(volume, current_spacing, target_spacing)

Resample a volume to a new spacing.

Module Contents#

linumpy.gpu.interpolation.affine_transform(image, matrix, output_shape=None, order=1, use_gpu=True)[source]#

GPU-accelerated affine transformation.

Parameters:
  • image (np.ndarray) – Input image (2D or 3D)

  • matrix (np.ndarray) – Affine transformation matrix

  • output_shape (tuple, optional) – Shape of output image. If None, uses input shape.

  • order (int) – Interpolation order (0=nearest, 1=linear, 3=cubic)

  • use_gpu (bool) – Whether to use GPU acceleration

Returns:

Transformed image

Return type:

np.ndarray

linumpy.gpu.interpolation.map_coordinates(image, coordinates, order=1, use_gpu=True)[source]#

GPU-accelerated coordinate mapping (general interpolation).

Parameters:
  • image (np.ndarray) – Input image

  • coordinates (np.ndarray) – Coordinates to sample at, shape (ndim, …)

  • order (int) – Interpolation order

  • use_gpu (bool) – Whether to use GPU

Returns:

Interpolated values

Return type:

np.ndarray

linumpy.gpu.interpolation.resize(image, output_shape, order=1, anti_aliasing=True, use_gpu=True)[source]#

GPU-accelerated image resize.

Parameters:
  • image (np.ndarray) – Input image

  • output_shape (tuple) – Desired output shape

  • order (int) – Interpolation order

  • anti_aliasing (bool) – Whether to apply anti-aliasing filter before downsampling

  • use_gpu (bool) – Whether to use GPU

Returns:

Resized image

Return type:

np.ndarray

linumpy.gpu.interpolation.apply_displacement_field(image, displacement_field, use_gpu=True)[source]#

Apply a displacement field to warp an image.

Parameters:
  • image (np.ndarray) – Input image (2D or 3D)

  • displacement_field (np.ndarray) – Displacement field with shape (ndim, *image.shape)

  • use_gpu (bool) – Whether to use GPU

Returns:

Warped image

Return type:

np.ndarray

linumpy.gpu.interpolation.resample_volume(volume, current_spacing, target_spacing, order=1, use_gpu=True)[source]#

Resample a volume to a new spacing.

Parameters:
  • volume (np.ndarray) – Input volume

  • current_spacing (tuple) – Current voxel spacing

  • target_spacing (tuple) – Target voxel spacing

  • order (int) – Interpolation order

  • use_gpu (bool) – Whether to use GPU

Returns:

Resampled volume

Return type:

np.ndarray