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 what shape and slice are.

  • If shape is given but slice is None, the returned ndarray is trimmed about the center of the array using lentil.pad().

  • If slice is given but shape is None, the returned ndarray is extracted from img according to the indices in slice

  • If both shape and slice are given, the returned ndarray is extracted from img according to the indices in slice 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)