lentil.window#
- lentil.window(img, shape=None, slice=None)[source]#
Extract an appropriately sized, potentially windowed array
- Parameters:
img (array_like) – Data to window
shape (array_like or None, optional) – Output shape given as (nrows, ncols). If
None
(default), an uncropped array is returned.slice (array_like or None, optional) – Indices of
img
array to return given as (r_start, r_end, c_start, c_end). This definition follows standard numpy indexing.
- Returns:
data – Trimmed and windowed
img
array- Return type:
ndarray
Notes
If
img
is a single value (img.size == 1), self.data is returned regardless of whatshape
andslice
are.If
shape
is given butslice
isNone
, the returned ndarray is trimmed about the center of the array usinglentil.pad()
.If
slice
is given butshape
isNone
, the returned ndarray is extracted fromimg
according to the indices inslice
If both
shape
andslice
are given, the returned ndarray is extracted fromimg
according to the indices inslice
and the following expressions must also be true:
shape[0] = (slice[1] - slice[0]) = (r_end - r_start) shape[1] = (slice[3] - slice[2]) = (c_end - c_start)