pydicom.pixel_data_handlers.convert_color_space

pydicom.pixel_data_handlers.convert_color_space(arr: numpy.ndarray, current: str, desired: str, per_frame: bool = False) numpy.ndarray[source]

Convert the image(s) in arr from one color space to another.

Changed in version 1.4: Added support for YBR_FULL_422

Changed in version 2.2: Added per_frame keyword parameter.

Parameters
  • arr (numpy.ndarray) – The image(s) as a numpy.ndarray with shape (frames, rows, columns, 3) or (rows, columns, 3).

  • current (str) – The current color space, should be a valid value for (0028,0004) Photometric Interpretation. One of 'RGB', 'YBR_FULL', 'YBR_FULL_422'.

  • desired (str) – The desired color space, should be a valid value for (0028,0004) Photometric Interpretation. One of 'RGB', 'YBR_FULL', 'YBR_FULL_422'.

  • per_frame (bool, optional) – If True and the input array contains multiple frames then process each frame individually to reduce memory usage. Default False.

Returns

The image(s) converted to the desired color space.

Return type

numpy.ndarray

References