pydicom.pixel_data_handlers.rle_handler¶
Use the numpy package to convert RLE lossless Pixel
Data to a numpy.ndarray
.
Supported transfer syntaxes
1.2.840.10008.1.2.5 : RLE Lossless
Supported data
The RLE handler supports the conversion of data in the (7FE0,0010) Pixel Data element to a numpy ndarray provided the related Image Pixel module elements have values given in the table below.
Element |
Supported values |
|||
---|---|---|---|---|
Tag |
Keyword |
Type |
||
(0028,0002) |
SamplesPerPixel |
1 |
N |
Required |
(0028,0006) |
PlanarConfiguration |
1C |
1 |
Optional |
(0028,0008) |
NumberOfFrames |
1C |
N |
Optional |
(0028,0010) |
Rows |
1 |
N |
Required |
(0028,0011) |
Columns |
1 |
N |
Required |
(0028,0100) |
BitsAllocated |
1 |
8, 16, 32 |
Required |
(0028,0103) |
PixelRepresentation |
1 |
0, 1 |
Required |
Functions
|
Return an |
Return |
|
Return |
|
|
Return an |
Return |
|
|
Return |
-
pydicom.pixel_data_handlers.rle_handler.
get_pixeldata
(ds, rle_segment_order='>')[source]¶ Return an
numpy.ndarray
of the Pixel Data.- Parameters
ds (dataset.Dataset) – The
Dataset
containing an Image Pixel module and the RLE encoded Pixel Data to be converted.rle_segment_order (str) – The order of segments used by the RLE decoder when dealing with Bits Allocated > 8. Each RLE segment contains 8-bits of the pixel data, and segments are supposed to be ordered from MSB to LSB. A value of
'>'
means interpret the segments as being in big endian order (default) while a value of'<'
means interpret the segments as being in little endian order which may be possible if the encoded data is non-conformant.
- Returns
The decoded contents of (7FE0,0010) Pixel Data as a 1D array.
- Return type
- Raises
AttributeError – If ds is missing a required element.
NotImplementedError – If ds contains pixel data in an unsupported format.
ValueError – If the actual length of the pixel data doesn’t match the expected length.
-
pydicom.pixel_data_handlers.rle_handler.
is_available
()[source]¶ Return
True
if the handler has its dependencies met.
-
pydicom.pixel_data_handlers.rle_handler.
needs_to_convert_to_RGB
(ds)[source]¶ Return
True
if the Pixel Data should to be converted from YCbCr to RGB.This affects JPEG transfer syntaxes.
-
pydicom.pixel_data_handlers.rle_handler.
rle_encode_frame
(arr)[source]¶ Return an
numpy.ndarray
image frame as RLE encodedbytearray
.New in version 1.3.
- Parameters
arr (numpy.ndarray) – A 2D (if Samples Per Pixel = 1) or 3D (if Samples Per Pixel = 3) ndarray containing a single frame of the image to be RLE encoded.
- Returns
An RLE encoded frame, including the RLE header, following the format specified by the DICOM Standard, Part 5, Annex G.
- Return type