Multidimensional image processing (cupyx.scipy.ndimage)#


convolve(input, weights[, output, mode, ...])

Multi-dimensional convolution.

convolve1d(input, weights[, axis, output, ...])

One-dimensional convolution.

correlate(input, weights[, output, mode, ...])

Multi-dimensional correlate.

correlate1d(input, weights[, axis, output, ...])

One-dimensional correlate.

gaussian_filter(input, sigma[, order, ...])

Multi-dimensional Gaussian filter.

gaussian_filter1d(input, sigma[, axis, ...])

One-dimensional Gaussian filter along the given axis.

gaussian_gradient_magnitude(input, sigma[, ...])

Multi-dimensional gradient magnitude using Gaussian derivatives.

gaussian_laplace(input, sigma[, output, ...])

Multi-dimensional Laplace filter using Gaussian second derivatives.

generic_filter(input, function[, size, ...])

Compute a multi-dimensional filter using the provided raw kernel or reduction kernel.

generic_filter1d(input, function, filter_size)

Compute a 1D filter along the given axis using the provided raw kernel.

generic_gradient_magnitude(input, derivative)

Multi-dimensional gradient magnitude filter using a provided derivative function.

generic_laplace(input, derivative2[, ...])

Multi-dimensional Laplace filter using a provided second derivative function.

laplace(input[, output, mode, cval])

Multi-dimensional Laplace filter based on approximate second derivatives.

maximum_filter(input[, size, footprint, ...])

Multi-dimensional maximum filter.

maximum_filter1d(input, size[, axis, ...])

Compute the maximum filter along a single axis.

median_filter(input[, size, footprint, ...])

Multi-dimensional median filter.

minimum_filter(input[, size, footprint, ...])

Multi-dimensional minimum filter.

minimum_filter1d(input, size[, axis, ...])

Compute the minimum filter along a single axis.

percentile_filter(input, percentile[, size, ...])

Multi-dimensional percentile filter.

prewitt(input[, axis, output, mode, cval])

Compute a Prewitt filter along the given axis.

rank_filter(input, rank[, size, footprint, ...])

Multi-dimensional rank filter.

sobel(input[, axis, output, mode, cval])

Compute a Sobel filter along the given axis.

uniform_filter(input[, size, output, mode, ...])

Multi-dimensional uniform filter.

uniform_filter1d(input, size[, axis, ...])

One-dimensional uniform filter along the given axis.

Fourier filters#

fourier_ellipsoid(input, size[, n, axis, output])

Multidimensional ellipsoid Fourier filter.

fourier_gaussian(input, sigma[, n, axis, output])

Multidimensional Gaussian shift filter.

fourier_shift(input, shift[, n, axis, output])

Multidimensional Fourier shift filter.

fourier_uniform(input, size[, n, axis, output])

Multidimensional uniform shift filter.


affine_transform(input, matrix[, offset, ...])

Apply an affine transformation.

map_coordinates(input, coordinates[, ...])

Map the input array to new coordinates by interpolation.

rotate(input, angle[, axes, reshape, ...])

Rotate an array.

shift(input, shift[, output, order, mode, ...])

Shift an array.

spline_filter(input[, order, output, mode])

Multidimensional spline filter.

spline_filter1d(input[, order, axis, ...])

Calculate a 1-D spline filter along the given axis.

zoom(input, zoom[, output, order, mode, ...])

Zoom an array.


center_of_mass(input[, labels, index])

Calculate the center of mass of the values of an array at labels.

extrema(input[, labels, index])

Calculate the minimums and maximums of the values of an array at labels, along with their positions.

histogram(input, min, max, bins[, labels, index])

Calculate the histogram of the values of an array, optionally at labels.

label(input[, structure, output])

Labels features in an array.

labeled_comprehension(input, labels, index, ...)

Array resulting from applying func to each labeled region.

maximum(input[, labels, index])

Calculate the maximum of the values of an array over labeled regions.

maximum_position(input[, labels, index])

Find the positions of the maximums of the values of an array at labels.

mean(input[, labels, index])

Calculates the mean of the values of an n-D image array, optionally

median(input[, labels, index])

Calculate the median of the values of an array over labeled regions.

minimum(input[, labels, index])

Calculate the minimum of the values of an array over labeled regions.

minimum_position(input[, labels, index])

Find the positions of the minimums of the values of an array at labels.

standard_deviation(input[, labels, index])

Calculates the standard deviation of the values of an n-D image array, optionally at specified sub-regions.

sum_labels(input[, labels, index])

Calculates the sum of the values of an n-D image array, optionally

variance(input[, labels, index])

Calculates the variance of the values of an n-D image array, optionally at specified sub-regions.


binary_closing(input[, structure, ...])

Multidimensional binary closing with the given structuring element.

binary_dilation(input[, structure, ...])

Multidimensional binary dilation with the given structuring element.

binary_erosion(input[, structure, ...])

Multidimensional binary erosion with a given structuring element.

binary_fill_holes(input[, structure, ...])

Fill the holes in binary objects.

binary_hit_or_miss(input[, structure1, ...])

Multidimensional binary hit-or-miss transform.

binary_opening(input[, structure, ...])

Multidimensional binary opening with the given structuring element.

binary_propagation(input[, structure, mask, ...])

Multidimensional binary propagation with the given structuring element.

black_tophat(input[, size, footprint, ...])

Multidimensional black tophat filter.

generate_binary_structure(rank, connectivity)

Generate a binary structure for binary morphological operations.

grey_closing(input[, size, footprint, ...])

Calculates a multi-dimensional greyscale closing.

grey_dilation(input[, size, footprint, ...])

Calculates a greyscale dilation.

grey_erosion(input[, size, footprint, ...])

Calculates a greyscale erosion.

grey_opening(input[, size, footprint, ...])

Calculates a multi-dimensional greyscale opening.

iterate_structure(structure, iterations[, ...])

Iterate a structure by dilating it with itself.

morphological_gradient(input[, size, ...])

Multidimensional morphological gradient.

morphological_laplace(input[, size, ...])

Multidimensional morphological laplace.

white_tophat(input[, size, footprint, ...])

Multidimensional white tophat filter.

OpenCV mode#

cupyx.scipy.ndimage supports additional mode, opencv. If it is given, the function performs like cv2.warpAffine or cv2.resize. Example:

import cupyx.scipy.ndimage
import cupy as cp
import cv2

im = cv2.imread('TODO') # pls fill in your image path

trans_mat = cp.eye(4)
trans_mat[0][0] = trans_mat[1][1] = 0.5

smaller_shape = (im.shape[0] // 2, im.shape[1] // 2, 3)
smaller = cp.zeros(smaller_shape) # preallocate memory for resized image

cupyx.scipy.ndimage.affine_transform(im, trans_mat, output_shape=smaller_shape,
                                     output=smaller, mode='opencv')

cv2.imwrite('smaller.jpg', cp.asnumpy(smaller)) # smaller image saved locally