dicom_encoding::adapters

Trait PixelDataReader

Source
pub trait PixelDataReader {
    // Required method
    fn decode_frame(
        &self,
        src: &dyn PixelDataObject,
        frame: u32,
        dst: &mut Vec<u8>,
    ) -> DecodeResult<()>;

    // Provided method
    fn decode(
        &self,
        src: &dyn PixelDataObject,
        dst: &mut Vec<u8>,
    ) -> DecodeResult<()> { ... }
}
Expand description

Trait object responsible for decoding pixel data based on the transfer syntax.

A transfer syntax with support for decoding encapsulated pixel data would implement these methods.

Required Methods§

Source

fn decode_frame( &self, src: &dyn PixelDataObject, frame: u32, dst: &mut Vec<u8>, ) -> DecodeResult<()>

Decode the given DICOM object containing encapsulated pixel data into native pixel data of a single frame as a byte stream in little endian, appending these bytes to the given vector dst.

The frame index is 0-based.

It is a necessary precondition that the object’s pixel data is encoded in accordance to the transfer syntax(es) supported by this adapter. A NotEncapsulated error is returned otherwise.

The output is a sequence of native pixel values of a frame which follow the image properties of the given object save for the photometric interpretation and planar configuration. If the image has 3 samples per pixel, the output must be in RGB with each pixel contiguous in memory (planar configuration of 0). For pixel data with a single sample per pixel, the output shall retain the photometric interpretation declared in the original object if it is one of MONOCHROME1, MONOCHROME2, or PALETTE COLOR. For any other photometric interpretation, the output shall be assumed to be in MONOCHROME2.

Provided Methods§

Source

fn decode( &self, src: &dyn PixelDataObject, dst: &mut Vec<u8>, ) -> DecodeResult<()>

Decode the given DICOM object containing encapsulated pixel data into native pixel data as a byte stream in little endian, appending these bytes to the given vector dst.

It is a necessary precondition that the object’s pixel data is encoded in accordance to the transfer syntax(es) supported by this adapter. A NotEncapsulated error is returned otherwise.

The output is a sequence of native pixel values which follow the image properties of the given object save for the photometric interpretation and planar configuration. If the image has 3 samples per pixel, the output must be in RGB with each pixel contiguous in memory (planar configuration of 0). However, if the image is monochrome, the output should retain the photometric interpretation of the source object (so that images in MONOCHROME1 continue to be in MONOCHROME1 and images in MONOCHROME2 continue to be in MONOCHROME2).

Implementors§