Struct dicom_pixeldata::Lut
source · [−]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
sourceimpl<T: 'static> Lut<T> where
T: NumCast,
T: Copy,
T: Send + Sync,
impl<T: 'static> Lut<T> where
T: NumCast,
T: Copy,
T: Send + Sync,
sourcepub fn new_with_fn(
bits_stored: u16,
signed: bool,
f: impl Fn(f64) -> f64 + Sync
) -> Result<Self, CreateLutError>
pub fn new_with_fn(
bits_stored: u16,
signed: bool,
f: impl Fn(f64) -> f64 + Sync
) -> Result<Self, CreateLutError>
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.
sourcepub fn new_rescale(
bits_stored: u16,
signed: bool,
rescale: Rescale
) -> Result<Self, CreateLutError>
pub fn new_rescale(
bits_stored: u16,
signed: bool,
rescale: Rescale
) -> Result<Self, CreateLutError>
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.
sourcepub fn new_rescale_and_window(
bits_stored: u16,
signed: bool,
rescale: Rescale,
voi: WindowLevelTransform
) -> Result<Self, CreateLutError>
pub fn new_rescale_and_window(
bits_stored: u16,
signed: bool,
rescale: Rescale,
voi: WindowLevelTransform
) -> Result<Self, CreateLutError>
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 parametersvoi
: the value of interest (VOI) function and parameters
Panics
Panics if bits_stored
is 0 or too large.
sourcepub fn new_window(
bits_stored: u16,
signed: bool,
voi: WindowLevelTransform
) -> Result<Self, CreateLutError>
pub fn new_window(
bits_stored: u16,
signed: bool,
voi: WindowLevelTransform
) -> Result<Self, CreateLutError>
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.
sourcepub fn get<I: 'static>(&self, sample_value: I) -> T where
I: Copy,
I: Into<u32>,
pub fn get<I: 'static>(&self, sample_value: I) -> T where
I: Copy,
I: Into<u32>,
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
.
sourcepub fn map_iter<'a, I: 'static>(
&'a self,
iter: impl IntoIterator<Item = I> + 'a
) -> impl Iterator<Item = T> + 'a where
I: Copy,
I: Into<u32>,
pub fn map_iter<'a, I: 'static>(
&'a self,
iter: impl IntoIterator<Item = I> + 'a
) -> impl Iterator<Item = T> + 'a where
I: Copy,
I: Into<u32>,
Adapts an iterator of pixel data sample values to an iterator of transformed values.
sourcepub fn map_par_iter<'a, I: 'static>(
&'a self,
iter: impl ParallelIterator<Item = I> + 'a
) -> impl ParallelIterator<Item = T> + 'a where
I: Copy,
I: Into<u32>,
pub fn map_par_iter<'a, I: 'static>(
&'a self,
iter: impl ParallelIterator<Item = I> + 'a
) -> impl ParallelIterator<Item = T> + 'a where
I: Copy,
I: Into<u32>,
Adapts a parallel iterator of pixel data sample values to a parallel iterator of transformed values.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for Lut<T> where
T: RefUnwindSafe,
impl<T> Send for Lut<T> where
T: Send,
impl<T> Sync for Lut<T> where
T: Sync,
impl<T> Unpin for Lut<T> where
T: Unpin,
impl<T> UnwindSafe for Lut<T> where
T: UnwindSafe,
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