pub struct Lut<T> { /* private fields */ }
Expand description

A look up table for pixel data sample value transformations.

Example

The LUT can be populated with common transformations via the functions new_rescale, new_window, and new_rescale_and_window. The function new_with_fn can be used to create a LUT with a custom function.

let bits_stored = 8;
let lut = Lut::new_rescale_and_window(
    bits_stored,
    false,
    Rescale::new(1., -1024.),
    WindowLevelTransform::new(
        VoiLutFunction::Linear,
        WindowLevel {
            width: 300.,
            center: 50.
        }
    ),
)?;

let val: u8 = lut.get(100_u8);

Implementations

Create a new LUT with the given characteristics and populates it with the outputs of the provided function. The function may be called concurrently.

  • bits_stored: the number of bits effectively used to represent the sample values (the Bits Stored DICOM attribute)
  • signed: whether the input sample values are expected to be signed (Pixel Representation = 1)
  • f: the mapping function
Panics

Panics if bits_stored is 0 or too large.

Create a new LUT containing only the modality rescale transformation.

  • bits_stored: the number of bits effectively used to represent the sample values (the Bits Stored DICOM attribute)
  • signed: whether the input sample values are expected to be signed (Pixel Representation = 1)
  • rescale: the rescale parameters
Panics

Panics if bits_stored is 0 or too large.

Create a new LUT containing the modality rescale transformation and the VOI transformation defined by a window level.

The amplitude of the output values goes from 0 to 2^n - 1, where n is the power of two which follows bits_stored (or itself if it is a power of two). For instance, if bits_stored is 12, the output values will go from 0 to 65535.

  • bits_stored: the number of bits effectively used to represent the sample values (the Bits Stored DICOM attribute)
  • signed: whether the input sample values are expected to be signed (Pixel Representation = 1)
  • rescale: the rescale parameters
  • voi: the value of interest (VOI) function and parameters
Panics

Panics if bits_stored is 0 or too large.

Create a new LUT containing a VOI transformation defined by a window level.

The amplitude of the output values goes from 0 to 2^n - 1, where n is the power of two which follows bits_stored (or itself if it is a power of two). For instance, if bits_stored is 12, the output values will go from 0 to 65535.

  • bits_stored: the number of bits effectively used to represent the sample values (the Bits Stored DICOM attribute)
  • signed: whether the input sample values are expected to be signed (Pixel Representation = 1)
  • voi: the value of interest (VOI) function and parameters
Panics

Panics if bits_stored is 0 or too large.

Apply the transformation to a single pixel sample value.

Although the input is expected to be one of u8, u16, or u32, this method works for signed sample values as well, with the bits reinterpreted as their unsigned counterpart.

Panics

Panics if sample_value is larger or equal to 2^bits_stored.

Adapts an iterator of pixel data sample values to an iterator of transformed values.

Adapts a parallel iterator of pixel data sample values to a parallel iterator of transformed values.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more