pydicom.pixels.utils.reshape_pixel_array

pydicom.pixels.utils.reshape_pixel_array(ds: Dataset, arr: np.ndarray) np.ndarray[source]

Return a reshaped numpy.ndarray arr.

Element

Supported values

Tag

Keyword

Type

(0028,0002)

SamplesPerPixel

1

N > 0

Required

(0028,0006)

PlanarConfiguration

1C

0, 1

Optional

(0028,0008)

NumberOfFrames

1C

N > 0

Optional

(0028,0010)

Rows

1

N > 0

Required

(0028,0011)

Columns

1

N > 0

Required

(0028,0008) Number of Frames is required when Pixel Data contains more than 1 frame. (0028,0006) Planar Configuration is required when (0028,0002) Samples per Pixel is greater than 1. For certain compressed transfer syntaxes it is always taken to be either 0 or 1 as shown in the table below.

Transfer Syntax

Planar Configuration

UID

Name

1.2.840.10008.1.2.4.50

JPEG Baseline

0

1.2.840.10008.1.2.4.57

JPEG Lossless, Non-hierarchical

0

1.2.840.10008.1.2.4.70

JPEG Lossless, Non-hierarchical, SV1

0

1.2.840.10008.1.2.4.80

JPEG-LS Lossless

0

1.2.840.10008.1.2.4.81

JPEG-LS Lossy

0

1.2.840.10008.1.2.4.90

JPEG 2000 Lossless

0

1.2.840.10008.1.2.4.91

JPEG 2000 Lossy

0

1.2.840.10008.1.2.5

RLE Lossless

1

Changed in version 2.1: JPEG-LS transfer syntaxes changed to Planar Configuration of 0

Parameters:
Returns:

A reshaped array containing the pixel data. The shape of the array depends on the contents of the dataset:

  • For single frame, single sample data (rows, columns)

  • For single frame, multi-sample data (rows, columns, samples)

  • For multi-frame, single sample data (frames, rows, columns)

  • For multi-frame, multi-sample data (frames, rows, columns, samples)

Return type:

numpy.ndarray

References