{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / util / _slice_along_axes / slice_along_axes

function

skimage.util._slice_along_axes:slice_along_axes

source: /dev/scikit-image/src/skimage/util/_slice_along_axes.py :4

Signature

def   slice_along_axes ( image slices axes = None copy = False )

Summary

Slice an image along given axes.

Parameters

image : ndarray

Input image.

slices : list of (tuple[int, int])

For each axis in axes, a corresponding 2-tuple (min_val, max_val) to slice with (as with Python slices, max_val is non-inclusive).

axes : int or tuple, optional

Axes corresponding to the limits given in slices. If None, axes are in ascending order, up to the length of slices.

copy : bool, optional

If True, ensure that the output is not a view of image.

Returns

out : ndarray

The region of image corresponding to the given slices and axes.

Examples

from skimage import data
img = data.camera()
img.shape
cropped_img = slice_along_axes(img, [(0, 100)])
cropped_img.shape
cropped_img = slice_along_axes(img, [(0, 100), (0, 100)])
cropped_img.shape
cropped_img = slice_along_axes(img, [(0, 100), (0, 75)], axes=[1, 0])
cropped_img.shape

Aliases

  • skimage.util.slice_along_axes