pydicom.pixels.apply_voi_lut

pydicom.pixels.apply_voi_lut(arr: np.ndarray, ds: Dataset, index: int = 0, prefer_lut: bool = True) np.ndarray[source]

Apply a VOI lookup table or windowing operation to arr.

Changed in version 2.1: Added the prefer_lut keyword parameter

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

  • ds (dataset.Dataset) – A dataset containing a VOI LUT Module. If (0028,3010) VOI LUT Sequence is present then returns an array of np.uint8 or np.uint16, depending on the 3rd value of (0028,3002) LUT Descriptor. If (0028,1050) Window Center and (0028,1051) Window Width are present then returns an array of np.float64. If neither are present then 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).

  • prefer_lut (bool) – When the VOI LUT Module contains both Window Width/Window Center and VOI LUT Sequence, if True (default) then apply the VOI LUT, otherwise apply the windowing operation.

Returns:

An array with applied VOI LUT or 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