pub struct WindowLevel {
pub center: f64,
pub width: f64,
}Expand description
DICOM window/level parameters.
center— the value that maps to the midpoint of the output range.width— the full span of input values that map to the full output range.
A width of zero is not meaningful; the caller should ensure width > 0.
Fields§
§center: f64Window centre (level).
width: f64Window width.
Implementations§
Source§impl WindowLevel
impl WindowLevel
Sourcepub fn apply(&self, value: f64, out_min: f64, out_max: f64) -> f64
pub fn apply(&self, value: f64, out_min: f64, out_max: f64) -> f64
Apply the DICOM linear mapping and return a value in [out_min, out_max].
out_min and out_max are typically 0.0 and 1.0 for GPU normalisation,
or 0.0 and 255.0 for 8-bit display.
Sourcepub fn denormalise(&self, t: f64) -> f64
pub fn denormalise(&self, t: f64) -> f64
Return the input value that maps to t ∈ [0, 1].
This is the inverse of WindowLevel::normalise.
Sourcepub fn adjust_center(&mut self, delta: f64)
pub fn adjust_center(&mut self, delta: f64)
Adjust the center by delta (level change).
Sourcepub fn adjust_width(&mut self, factor: f64)
pub fn adjust_width(&mut self, factor: f64)
Adjust the width by factor (window change, multiplicative).
The width is clamped to at least 1.0 to avoid division by zero.
Sourcepub fn from_scalar_range(min: f64, max: f64) -> Self
pub fn from_scalar_range(min: f64, max: f64) -> Self
Derive window/level from a scalar range.
Sets center to the midpoint and width to the full range (minimum 1.0).
Trait Implementations§
Source§impl Clone for WindowLevel
impl Clone for WindowLevel
Source§fn clone(&self) -> WindowLevel
fn clone(&self) -> WindowLevel
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for WindowLevel
impl Debug for WindowLevel
Source§impl PartialEq for WindowLevel
impl PartialEq for WindowLevel
impl Copy for WindowLevel
impl StructuralPartialEq for WindowLevel
Auto Trait Implementations§
impl Freeze for WindowLevel
impl RefUnwindSafe for WindowLevel
impl Send for WindowLevel
impl Sync for WindowLevel
impl Unpin for WindowLevel
impl UnsafeUnpin for WindowLevel
impl UnwindSafe for WindowLevel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more