Struct dicom_pixeldata::DecodedPixelData
source · [−]pub struct DecodedPixelData<'a> { /* private fields */ }
Expand description
A blob of decoded pixel data.
This is the outcome of collecting a DICOM object’s imaging-related attributes
into a decoded form.
The decoded pixel data samples will be stored as raw bytes in native form
without any LUT transformations applied.
Whether to apply such transformations
can be specified through one of the various to_*
methods,
such as to_dynamic_image
and to_vec
.
Implementations
sourceimpl DecodedPixelData<'_>
impl DecodedPixelData<'_>
sourcepub fn data(&self) -> &[u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
pub fn data(&self) -> &[u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
Retrieve a slice of all raw pixel data samples as bytes, irrespective of the expected size of each sample.
sourcepub fn data_ow(&self) -> Vec<u16>
pub fn data_ow(&self) -> Vec<u16>
Retrieve a copy of all raw pixel data samples as unsigned 16-bit integers.
This is useful for retrieving pixel data with the OW value representation.
sourcepub fn frame_data(&self, frame: u32) -> Result<&[u8]>
pub fn frame_data(&self, frame: u32) -> Result<&[u8]>
Retrieve a slice of a frame’s raw pixel data samples as bytes, irrespective of the expected size of each sample.
sourcepub fn frame_data_ow(&self, frame: u32) -> Result<Vec<u16>>
pub fn frame_data_ow(&self, frame: u32) -> Result<Vec<u16>>
Retrieve a copy of a frame’s raw pixel data samples as unsigned 16-bit integers.
This is useful for retrieving pixel data with the OW value representation.
sourcepub fn photometric_interpretation(&self) -> &PhotometricInterpretation
pub fn photometric_interpretation(&self) -> &PhotometricInterpretation
Retrieves the photometric interpretation.
sourcepub fn planar_configuration(&self) -> PlanarConfiguration
pub fn planar_configuration(&self) -> PlanarConfiguration
Retrieves the planar configuration of the pixel data.
The value returned is only meaningful for images with more than 1 sample per pixel.
sourcepub fn number_of_frames(&self) -> u32
pub fn number_of_frames(&self) -> u32
Retrieves the total number of frames in this piece of decoded pixel data.
sourcepub fn samples_per_pixel(&self) -> u16
pub fn samples_per_pixel(&self) -> u16
Retrieves the number of samples per pixel.
sourcepub fn bits_stored(&self) -> u16
pub fn bits_stored(&self) -> u16
Retrieve the number of bits effectively used for each sample.
sourcepub fn bits_allocated(&self) -> u16
pub fn bits_allocated(&self) -> u16
Retrieve the number of bits allocated for each sample.
sourcepub fn pixel_representation(&self) -> PixelRepresentation
pub fn pixel_representation(&self) -> PixelRepresentation
Retrieve the pixel representation.
sourcepub fn voi_lut_function(&self) -> Option<VoiLutFunction>
pub fn voi_lut_function(&self) -> Option<VoiLutFunction>
Retrieve the VOI LUT function defined by the object, if any.
sourcepub fn to_dynamic_image(&self, frame: u32) -> Result<DynamicImage>
pub fn to_dynamic_image(&self, frame: u32) -> Result<DynamicImage>
Convert the decoded pixel data of a specific frame into a dynamic image.
The default pixel data process pipeline
applies the Modality LUT function,
followed by the first VOI LUT transformation found in the object.
To change this behavior,
see to_dynamic_image_with_options
.
sourcepub fn to_dynamic_image_with_options(
&self,
frame: u32,
options: &ConvertOptions
) -> Result<DynamicImage>
pub fn to_dynamic_image_with_options(
&self,
frame: u32,
options: &ConvertOptions
) -> Result<DynamicImage>
Convert the decoded pixel data of a specific frame into a dynamic image.
The options
value allows you to specify
which transformations should be done to the pixel data
(primarily Modality LUT function and VOI LUT function).
By default, both Modality and VOI LUT functions are applied
according to the attributes of the given object.
Note that certain options may be ignored
if they do not apply.
Example
let options = ConvertOptions::new()
.with_voi_lut(VoiLutOption::Custom(WindowLevel {
center: -300.0,
width: 600.,
}));
let img = data.to_dynamic_image_with_options(0, &options)?;
sourcepub fn to_vec<T: 'static>(&self) -> Result<Vec<T>> where
T: NumCast,
T: Send + Sync,
T: Copy,
pub fn to_vec<T: 'static>(&self) -> Result<Vec<T>> where
T: NumCast,
T: Send + Sync,
T: Copy,
Convert all of the decoded pixel data into a vector of flat pixels
of a given type T
.
The underlying pixel data type is extracted based on the bits allocated and pixel representation, which is then converted to the requested type. Photometric interpretation is ignored.
The default pixel data process pipeline
applies only the Modality LUT function.
To change this behavior,
see to_vec_with_options
.
Example
// get the pixels of all frames as 32-bit modality values
let all_pixels: Vec<f32> = data.to_vec()?;
sourcepub fn to_vec_with_options<T: 'static>(
&self,
options: &ConvertOptions
) -> Result<Vec<T>> where
T: NumCast,
T: Send + Sync,
T: Copy,
pub fn to_vec_with_options<T: 'static>(
&self,
options: &ConvertOptions
) -> Result<Vec<T>> where
T: NumCast,
T: Send + Sync,
T: Copy,
Convert all of the decoded pixel data into a vector of flat pixels
of a given type T
.
The underlying pixel data type is extracted based on the bits allocated and pixel representation, which is then converted to the requested type. Photometric interpretation is ignored.
The options
value allows you to specify
which transformations should be done to the pixel data
(primarily Modality LUT function and VOI LUT function).
By default, only the Modality LUT function is applied.
sourcepub fn to_vec_frame<T: 'static>(&self, frame: u32) -> Result<Vec<T>> where
T: NumCast,
T: Send + Sync,
T: Copy,
pub fn to_vec_frame<T: 'static>(&self, frame: u32) -> Result<Vec<T>> where
T: NumCast,
T: Send + Sync,
T: Copy,
Convert the decoded pixel data of a frame
into a vector of flat pixels of a given type T
.
The underlying pixel data type is extracted based on the bits allocated and pixel representation, which is then converted to the requested type. Photometric interpretation is ignored.
The default pixel data process pipeline
applies only the Modality LUT function.
To change this behavior,
see to_vec_frame_with_options
.
sourcepub fn to_vec_frame_with_options<T: 'static>(
&self,
frame: u32,
options: &ConvertOptions
) -> Result<Vec<T>> where
T: NumCast,
T: Send + Sync,
T: Copy,
pub fn to_vec_frame_with_options<T: 'static>(
&self,
frame: u32,
options: &ConvertOptions
) -> Result<Vec<T>> where
T: NumCast,
T: Send + Sync,
T: Copy,
Convert the decoded pixel data of a frame
into a vector of flat pixels of a given type T
.
The underlying pixel data type is extracted based on
the bits allocated and pixel representation,
which is then converted to the requested type.
Photometric interpretation is considered
to identify whether rescaling should be applied.
The pixel values are not inverted
if photometric interpretation is MONOCHROME1
.
The options
value allows you to specify
which transformations should be done to the pixel data
(primarily Modality LUT function and VOI LUT function).
By default, only the Modality LUT function is applied
according to the attributes of the given object.
Note that certain options may be ignored
if they do not apply.
Example
let options = ConvertOptions::new()
.with_voi_lut(VoiLutOption::Custom(WindowLevel {
center: -300.0,
width: 600.,
}));
// get the pixels of the first frame with 8 bits per channel
let first_frame_pixels: Vec<u8> = data.to_vec_frame_with_options(0, &options)?;
sourcepub fn to_ndarray<T: 'static>(&self) -> Result<Array<T, Ix4>> where
T: NumCast,
T: Copy,
T: Send + Sync,
pub fn to_ndarray<T: 'static>(&self) -> Result<Array<T, Ix4>> where
T: NumCast,
T: Copy,
T: Send + Sync,
Convert all of the decoded pixel data
into a four dimensional array of a given type T
.
The underlying pixel data type is extracted based on
the bits allocated and pixel representation,
which is then converted to the requested type.
Photometric interpretation is considered
to identify whether rescaling should be applied.
The pixel values are not inverted
if photometric interpretation is MONOCHROME1
.
The shape of the array will be [N, R, C, S]
,
where N
is the number of frames,
R
is the number of rows,
C
is the number of columns,
and S
is the number of samples per pixel.
The default pixel data process pipeline
applies only the Modality LUT function described in the object,
To change this behavior,
see to_ndarray_with_options
.
sourcepub fn to_ndarray_with_options<T: 'static>(
&self,
options: &ConvertOptions
) -> Result<Array<T, Ix4>> where
T: NumCast,
T: Copy,
T: Send + Sync,
pub fn to_ndarray_with_options<T: 'static>(
&self,
options: &ConvertOptions
) -> Result<Array<T, Ix4>> where
T: NumCast,
T: Copy,
T: Send + Sync,
Convert all of the decoded pixel data
into a four dimensional array of a given type T
.
The underlying pixel data type is extracted based on
the bits allocated and pixel representation,
which is then converted to the requested type.
Photometric interpretation is considered
to identify whether rescaling should be applied.
The pixel values are not inverted
if photometric interpretation is MONOCHROME1
.
The shape of the array will be [N, R, C, S]
,
where N
is the number of frames,
R
is the number of rows,
C
is the number of columns,
and S
is the number of samples per pixel.
The options
value allows you to specify
which transformations should be done to the pixel data
(primarily Modality LUT function and VOI LUT function).
By default,
only the Modality LUT function described in the object is applied.
Note that certain options may be ignored
if they do not apply.
sourcepub fn to_ndarray_frame<T: 'static>(&self, frame: u32) -> Result<Array<T, Ix3>> where
T: NumCast,
T: Copy,
T: Send + Sync,
pub fn to_ndarray_frame<T: 'static>(&self, frame: u32) -> Result<Array<T, Ix3>> where
T: NumCast,
T: Copy,
T: Send + Sync,
Convert the decoded pixel data of a single frame
into a three dimensional array of a given type T
.
The underlying pixel data type is extracted based on
the bits allocated and pixel representation,
which is then converted to the requested type.
Photometric interpretation is considered
to identify whether rescaling should be applied.
The pixel values are not inverted
if photometric interpretation is MONOCHROME1
.
The shape of the array will be [R, C, S]
,
where R
is the number of rows,
C
is the number of columns,
and S
is the number of samples per pixel.
The default pixel data process pipeline
applies only the Modality LUT function described in the object,
To change this behavior,
see to_ndarray_frame_with_options
.
sourcepub fn to_ndarray_frame_with_options<T: 'static>(
&self,
frame: u32,
options: &ConvertOptions
) -> Result<Array<T, Ix3>> where
T: NumCast,
T: Copy,
T: Send + Sync,
pub fn to_ndarray_frame_with_options<T: 'static>(
&self,
frame: u32,
options: &ConvertOptions
) -> Result<Array<T, Ix3>> where
T: NumCast,
T: Copy,
T: Send + Sync,
Convert the decoded pixel data of a single frame
into a three dimensional array of a given type T
.
The underlying pixel data type is extracted based on
the bits allocated and pixel representation,
which is then converted to the requested type.
Photometric interpretation is considered
to identify whether rescaling should be applied.
The pixel values are not inverted
if photometric interpretation is MONOCHROME1
.
The shape of the array will be [R, C, S]
,
where R
is the number of rows,
C
is the number of columns,
and S
is the number of samples per pixel.
The options
value allows you to specify
which transformations should be done to the pixel data
(primarily Modality LUT function and VOI LUT function).
By default,
only the Modality LUT function described in the object is applied.
Note that certain options may be ignored
if they do not apply.
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for DecodedPixelData<'a>
impl<'a> Send for DecodedPixelData<'a>
impl<'a> Sync for DecodedPixelData<'a>
impl<'a> Unpin for DecodedPixelData<'a>
impl<'a> UnwindSafe for DecodedPixelData<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more