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
imgarray to return given as (r_start, r_end, c_start, c_end). This definition follows standard numpy indexing.
- Returns:
data – Trimmed and windowed
imgarray- Return type:
ndarray
Notes
If
imgis a single value (img.size == 1), self.data is returned regardless of whatshapeandsliceare.If
shapeis given butsliceisNone, the returned ndarray is trimmed about the center of the array usinglentil.pad().If
sliceis given butshapeisNone, the returned ndarray is extracted fromimgaccording to the indices insliceIf both
shapeandsliceare given, the returned ndarray is extracted fromimgaccording to the indices insliceand 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)