pydicom.encaps.generate_fragments

pydicom.encaps.generate_fragments(buffer: bytes | bytearray | ReadableBuffer, *, endianness: str = '<') Iterator[bytes][source]

Yield frame fragments from the encapsulated pixel data in buffer.

Added in version 3.0.

Parameters:
  • buffer (bytes | bytearray | readable buffer) – A buffer containing the encapsulated frame data, starting at the first byte of item tag for a fragment, usually this will be after the end of the Basic Offset Table. May be bytes, bytearray or an object with read(), tell() and seek() methods. If the latter than the final offset position depends on how many fragments have been yielded.

  • endianness (str, optional) – If "<" (default) then the encapsulated data uses little endian encoding, otherwise if ">" it uses big endian encoding.

Yields:

bytes – A pixel data fragment.