pydicom.encaps.encapsulate_extended¶
- pydicom.encaps.encapsulate_extended(frames: list[bytes]) tuple[bytes, bytes, bytes] [source]¶
Return encapsulated image data and values for the Extended Offset Table elements.
When using a compressed transfer syntax (such as RLE Lossless or one of JPEG formats) then any Pixel Data must be encapsulated. When many large frames are to be encapsulated, the total length of encapsulated data may exceed the maximum offset available with the Basic Offset Table (2**32 - 1 bytes). Under these circumstances you can:
Use
encapsulate_extended()
and add the Extended Offset Table elements to your dataset (recommended)Pass
has_bot=False
toencapsulate()
Examples
from pydicom import Dataset, FileMetaDataset from pydicom.encaps import encapsulate_extended from pydicom.uid import JPEG2000Lossless # 'frames' is a list of image frames that have been each been encoded # separately using the compression method corresponding to the Transfer # Syntax UID frames: list[bytes] = [...] out: tuple[bytes, bytes, bytes] = encapsulate_extended(frames) ds = Dataset() ds.file_meta = FileMetaDataset() ds.file_meta.TransferSyntaxUID = JPEG2000Lossless ds.PixelData = out[0] ds.ExtendedOffsetTable = out[1] ds.ExtendedOffsetTableLengths = out[2]