pydicom.pixels.encoders.base.EncodeRunner¶
- class pydicom.pixels.encoders.base.EncodeRunner(tsyntax: UID)[source]¶
Class for managing the pixel data encoding process.
Added in version 3.0.
This class is not intended to be used directly. For encoding pixel data use the
Encoder
instance corresponding to the transfer syntax of the pixel data.- __init__(tsyntax: UID) None [source]¶
Create a new runner for encoding data as tsyntax.
- Parameters:
tsyntax (pydicom.uid.UID) – The transfer syntax UID corresponding to the pixel data to be encoded.
Methods
__init__
(tsyntax)Create a new runner for encoding data as tsyntax.
del_option
(name)Delete option name from the runner.
encode
(index)Return an encoded frame of pixel data as
bytes
.frame_length
([unit])Return the expected length (in number of bytes or pixels) of each frame of pixel data.
get_frame
(index)Return a frame's worth of uncompressed pixel data as
bytes
.get_option
(name[, default])Return the value of the option name.
set_encoders
(encoders)Set the encoders use for encoding compressed pixel data.
set_option
(name, value)Set a runner option.
set_options
(**kwargs)Set multiple runner options.
set_source
(src)Set the pixel data to be encoded.
validate
()Validate the encoding options and source pixel data.
Attributes
Return the expected number of bits allocated used by the data.
Return the expected number of bits stored used by the data.
Return the expected number of columns in the data.
Return the extended offsets table and lengths
Return
True
if the pixel data source is anndarray
Return
True
if the pixel data source is BinaryIOReturn
True
if the pixel data source is a buffer-likeReturn
True
if the pixel data source is aDataset
Return the expected number of frames in the data.
Return a reference to the runner's options dict.
Return the expected photometric interpretation of the data.
Return the expected pixel keyword of the data.
Return the expected pixel representation of the data.
Return the expected planar configuration of the data.
Return the expected number of rows in the data.
Return the expected number of samples per pixel in the data.
Return the buffer-like or
numpy.ndarray
containing the pixel data.Return the expected transfer syntax corresponding to the data.
- property extended_offsets: tuple[list[int], list[int]] | tuple[bytes, bytes] | None¶
Return the extended offsets table and lengths
- frame_length(unit: str = 'bytes') int | float [source]¶
Return the expected length (in number of bytes or pixels) of each frame of pixel data.
- Parameters:
unit (str, optional) – If
"bytes"
then returns the expected length of the pixel data in whole bytes and NOT including an odd length trailing NULL padding byte. If"pixels"
then returns the expected length of the pixel data in terms of the total number of pixels (default"bytes"
).- Returns:
The expected length of a single frame of pixel data in either whole bytes or pixels, excluding the NULL trailing padding byte for odd length data. For “pixels”, an integer will always be returned. For “bytes”, a float will be returned for images with BitsAllocated of 1 whose frames do not consist of a whole number of bytes.
- Return type:
- get_frame(index: int | None) bytes [source]¶
Return a frame’s worth of uncompressed pixel data as
bytes
.- Parameters:
index (int | None) – If the pixel data only has one from then use
None
, otherwise index is the index of the frame to be returned.
- get_option(name: str, default: Any | None = None) Any [source]¶
Return the value of the option name.
- property options: DecodeOptions | EncodeOptions¶
Return a reference to the runner’s options dict.
- property photometric_interpretation: str¶
Return the expected photometric interpretation of the data.
- property pixel_keyword: str¶
Return the expected pixel keyword of the data.
- Returns:
One of
"PixelData"
,"FloatPixelData"
,"DoubleFloatPixelData"
- Return type:
- set_encoders(encoders: dict[str, Callable[[bytes, EncodeRunner], bytes | bytearray]]) None [source]¶
Set the encoders use for encoding compressed pixel data.
- set_option(name: str, value: Any) None [source]¶
Set a runner option.
- Parameters:
name (str) – The name of the option to be set.
value (Any) – The value of the option.
- set_source(src: np.ndarray | Dataset | Buffer) None [source]¶
Set the pixel data to be encoded.
- Parameters:
src (bytes | bytearray | memoryview | pydicom.dataset.Dataset | numpy.ndarray) –
If a buffer-like then the encoded pixel data
If a
Dataset
then a dataset containing the pixel data and associated group0x0028
elements.If a
numpy.ndarray
then an array containing the image data.
- property src: bytes | bytearray | memoryview | ndarray¶
Return the buffer-like or
numpy.ndarray
containing the pixel data.