pydicom.pixels.processing.apply_icc_profile¶
- pydicom.pixels.processing.apply_icc_profile(arr: np.ndarray, ds: Dataset | None = None, transform: PIL.ImageCms.ImageCmsTransform | None = None, intent: int | None = None, color_space: str | None = None) np.ndarray [source]¶
Apply an ICC Profile to arr, either from the dataset ds or an existing Pillow color transformation object transform.
Added in version 3.0.
- Parameters:
arr (numpy.ndarray) – 8-bit RGB pixel data to apply an ICC profile to, shaped as either (rows, columns, samples) or (frames, rows, columns, samples).
ds (pydicom.dataset.Dataset, optional) – Required if transform is not supplied, a
Dataset
containing elements from the ICC Profile module.transform (PIL.ImageCms.ImageCmsTransform, optional) – An
ImageCmsTransform
instance such as is returned by thecreate_icc_transform()
function. Required if ds is not used and recommended when the same ICC profile is to be re-used on multiple ndarrays.intent (int, optional) –
If transform is not supplied this is the rendering intent of the transformation that will be created from ds, one of:
0
: perceptual1
: relative colorimetric2
: saturation3
: absolute colorimetric
If no intent is specified then the default rendering intent in the ICC profile will be used.
color_space (str, optional) – If transform is not supplied this is 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 thesupported Pillow color spaces
, although in practice only"sRGB"
is likely to be used.
- Returns:
The input ndarray with the color transformation applied in-place.
- Return type:
np.ndarray