pydicom.pixels.apply_windowing

pydicom.pixels.apply_windowing(arr: np.ndarray, ds: Dataset, index: int = 0) np.ndarray[source]

Apply a windowing operation to arr.

Added in version 2.1.

Parameters:
  • arr (numpy.ndarray) – The ndarray to apply the windowing operation to.

  • ds (dataset.Dataset) – A dataset containing a VOI LUT Module. If (0028,1050) Window Center and (0028,1051) Window Width are present then returns an array of np.float64, otherwise arr will be returned unchanged.

  • index (int, optional) – When the VOI LUT Module contains multiple alternative views, this is the index of the view to return (default 0).

Returns:

An array with applied windowing operation.

Return type:

numpy.ndarray

Notes

When the dataset requires a modality LUT or rescale operation as part of the Modality LUT module then that must be applied before any windowing operation.

References