skimage2.util.slice_along_axes#

skimage2.util.slice_along_axes(image, slices, axes=None, copy=False)[source]#

Slice an image along given axes.

Parameters:
imagendarray

Input image.

sliceslist 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).

axesint or tuple, optional

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

copybool, optional

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

Returns:
outndarray

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

Examples

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