Expand description

This crate contains the DICOM pixel data handlers and is responsible for decoding various forms of native and compressed pixel data, such as JPEG lossless, and convert it into more usable data structures.

dicom-pixeldata currently supports a small, but increasing number of DICOM image encodings in pure Rust. As a way to mitigate the current gap, this library has an integration with GDCM bindings for an extended range of encodings. This integration is behind the Cargo feature “gdcm”, which requires CMake and a C++ compiler.

dicom-pixeldata = { version = "0.1", features = ["gdcm"] }

Once the pixel data is decoded, the decoded data can be converted to:

This conversion includes eventual Modality and value of interest (VOI) transformations.

WebAssembly support

This library works in WebAssembly by ensuring that the “gdcm” feature is disabled. This allows the crate to be compiled for WebAssembly albeit at the cost of supporting a lesser variety of compression algorithms.

Examples

To convert a DICOM object into a dynamic image:

use dicom_object::open_file;
use dicom_pixeldata::PixelDecoder;
let obj = open_file("dicom.dcm")?;
let image = obj.decode_pixel_data()?;
let dynamic_image = image.to_dynamic_image(0)?;
dynamic_image.save("out.png")?;

To convert a DICOM object into an ndarray:

use dicom_object::open_file;
use dicom_pixeldata::PixelDecoder;
use ndarray::s;
let obj = open_file("rgb_dicom.dcm")?;
let pixel_data = obj.decode_pixel_data()?;
let ndarray = pixel_data.to_ndarray::<u16>()?;
let red_values = ndarray.slice(s![.., .., .., 0]);

In order to parameterize the conversion, pass a conversion options valueto the _with_options variant methods.

use dicom_object::open_file;
use dicom_pixeldata::{ConvertOptions, PixelDecoder, VoiLutOption};
let obj = open_file("dicom.dcm")?;
let image = obj.decode_pixel_data()?;
let options = ConvertOptions::new()
    .with_voi_lut(VoiLutOption::Normalize)
    .force_8bit();
let dynamic_image = image.to_dynamic_image(0)?;

See ConvertOptions for the options available, including the default behavior for each method.

Re-exports

pub use image;
pub use ndarray;

Structs

Option set for converting decoded pixel data into other common data structures, such as a vector, an image, or a multidimensional array.

The LUT could not be created: entry #{index} was mapped to {y_value}, which could not be cast to the target type.

A blob of decoded pixel data.

Error type for most pixel data related operations.

A look up table for pixel data sample value transformations.

Description of a modality rescale function, defined by a rescale slope and rescale intercept.

The parameters of a single window level for a VOI LUT transformation, comprising the window center and the window width.

A full description of a VOI LUT function transformation based on a window level.

Enums

Output iamge bit depth specifier.

Inner error type

Modality LUT function specifier.

A decoded representation of the DICOM Photometric Interpretation attribute.

A decoded representation of the DICOM Pixel Representation attribute.

A decoded representation of the DICOM Planar Configuration attribute.

A known DICOM Value of Interest (VOI) LUT function descriptor.

VOI LUT function specifier.

Traits

Type Definitions