bounds2slices¶
- bounds2slices(bounds, stride=1)[source]¶
Convert bounds to slices.
Create a tuple of slices for each start/stop pair in bounds.
- Parameters:
- Returns:
Tuple of slices in image read order (y, x, channels).
- Return type:
Example
>>> from tiatoolbox.utils.transforms import bounds2slices >>> import numpy as np >>> bounds = (5, 5, 10, 10) >>> array = np.ones((10, 10, 3)) >>> slices = bounds2slices(bounds) >>> region = array[slices, ...]