# pydicom.pixels.processing.apply_modality_lut

pydicom.pixels.processing.apply_modality_lut(arr: np.ndarray, ds: Dataset) → np.ndarray

  Apply a modality lookup table or rescale operation to arr.

  Parameters:

    - arr (numpy.ndarray) – The `ndarray` to apply the modality LUT or rescale operation to.

    - ds (dataset.Dataset) – A dataset containing a Modality LUT Module.

  Returns:

    An array with applied modality LUT or rescale operation. If (0028,3000) Modality 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,1052) Rescale Intercept and (0028,1053) Rescale Slope are present then returns an array of `np.float64`. If neither are present then arr will be returned unchanged.

  Return type:

    numpy.ndarray

  Notes

  When Rescale Slope and Rescale Intercept are used, the output range is from (min. pixel value * Rescale Slope + Rescale Intercept) to (max. pixel value * Rescale Slope + Rescale Intercept), where min. and max. pixel value are determined from (0028,0101) Bits Stored and (0028,0103) Pixel Representation.

  References

  - DICOM Standard, Part 3, Annex C.11.1

  - DICOM Standard, Part 4, Annex N.2.1.1