pydicom.pixels.processing.create_icc_transform

pydicom.pixels.processing.create_icc_transform(ds: Dataset | None = None, icc_profile: bytes = b'', intent: int | None = None, color_space: str | None = None) PIL.ImageCms.ImageCmsTransform[source]

Return a Pillow color transformation object from either the dataset ds or an ICC profile icc_profile.

Added in version 3.0.

Warning

This function requires NumPy and Pillow.

Parameters:
  • ds (pydicom.dataset.Dataset, optional) – Required if icc_profile is not supplied, a Dataset containing elements from the ICC Profile module.

  • icc_profile (bytes, optional) – Required if ds is not supplied, an ICC profile encoded as bytes.

  • intent (int, optional) –

    The rendering intent of the transformation, one of:

    • 0: perceptual

    • 1: relative colorimetric

    • 2: saturation

    • 3: absolute colorimetric

    If no intent is specified then the default rendering intent in the ICC profile will be used.

  • color_space (str, optional) – The output color space to use for the transformation created from ds. If not used then defaults to the (0028,2002) Color Space value if its present in ds, otherwise defaults to "sRGB". If used then it will override the (0028,2002) Color Space element value (if present). Must be one of the supported Pillow color spaces, although in practice only "sRGB" is likely to be used.

Returns:

A color transformation object that can be used with apply_icc_profile().

Return type:

PIL.ImageCms.ImageCmsTransform