pydicom.pixel_data_handlers.pylibjpeg_handler¶
Use the pylibjpeg package
to convert supported pixel data to a numpy.ndarray.
Added in version 2.1.
Supported data
The pylibjpeg handler supports the conversion of data in the (7FE0,0010)
Pixel Data elements to a 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 | 1, 3 | Required | 
| (0028,0004) | PhotometricInterpretation | 1 | MONOCHROME1, MONOCHROME2, RGB, YBR_FULL, YBR_FULL_422, YBR_ICT, YBR_RCT | Required | 
| (0028,0006) | PlanarConfiguration | 1C | 0, 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 | Required | 
| (0028,0101) | BitsStored | 1 | Up to 16 | Required | 
| (0028,0103) | PixelRepresentation | 1 | 0, 1 | Required | 
Changed in version 2.2: Added support for RLE Lossless via the pylibjpeg-rle plugin.
Functions
| 
 | Return the entire Pixel Data as an  | 
| 
 | Yield a Pixel Data frame from ds as an  | 
| 
 | Return a  | 
| Return  | |
| Return  | |
| Return  | |
| 
 | Return  | 
- pydicom.pixel_data_handlers.pylibjpeg_handler.as_array(ds: Dataset) np.ndarray[source]¶
- Return the entire Pixel Data as an - ndarray.- Added in version 2.1. - Parameters:
- ds (pydicom.dataset.Dataset) – The - Datasetcontaining an Image Pixel module and the Pixel Data to be converted.
- Returns:
- The contents of (7FE0,0010) Pixel Data as an - ndarraywith shape (rows, columns), (rows, columns, components), (frames, rows, columns), or (frames, rows, columns, components) depending on the dataset.
- Return type:
 
- pydicom.pixel_data_handlers.pylibjpeg_handler.generate_frames(ds: Dataset, reshape: bool = True) Iterable[np.ndarray][source]¶
- Yield a Pixel Data frame from ds as an - ndarray.- Added in version 2.1. - Parameters:
- ds (pydicom.dataset.Dataset) – The - Datasetcontaining an Image Pixel module and the Pixel Data to be converted.
- reshape (bool, optional) – If - True(default), then the returned- ndarraywill be reshaped to the correct dimensions. If- Falsethen no reshaping will be performed.
 
- Yields:
- numpy.ndarray – A single frame of (7FE0,0010) Pixel Data as an - ndarraywith an appropriate dtype for the data.
- Raises:
- AttributeError – If ds is missing a required element. 
- RuntimeError – If the plugin required to decode the pixel data is not installed. 
 
 
- pydicom.pixel_data_handlers.pylibjpeg_handler.get_pixeldata(ds: Dataset) np.ndarray[source]¶
- Return a - numpy.ndarrayof the pixel data.- Added in version 2.1. - Parameters:
- ds (pydicom.dataset.Dataset) – The - Datasetcontaining an Image Pixel module and the Pixel Data to be converted.
- Returns:
- The contents of (7FE0,0010) Pixel Data as a 1D array. 
- Return type:
 
- pydicom.pixel_data_handlers.pylibjpeg_handler.is_available() bool[source]¶
- Return - Trueif the handler has its dependencies met.
- pydicom.pixel_data_handlers.pylibjpeg_handler.needs_to_convert_to_RGB(ds: Dataset) bool[source]¶
- Return - Trueif the Pixel Data should to be converted from YCbCr to RGB.- This affects JPEG transfer syntaxes. 
- pydicom.pixel_data_handlers.pylibjpeg_handler.should_change_PhotometricInterpretation_to_RGB(ds: Dataset) bool[source]¶
- Return - Trueif the Photometric Interpretation should be changed to RGB.- This affects JPEG transfer syntaxes. 
- pydicom.pixel_data_handlers.pylibjpeg_handler.supports_transfer_syntax(tsyntax: UID) bool[source]¶
- Return - Trueif the handler supports the tsyntax.- Parameters:
- tsyntax (pydicom.uid.UID) – The Transfer Syntax UID of the Pixel Data that is to be used with the handler.