Skip to content

Commit

Permalink
Merge pull request #598 from feliwir/custom-voi-function
Browse files Browse the repository at this point in the history
[pixeldata] Allow overriding the VoiLutFunction
  • Loading branch information
Enet4 authored Dec 7, 2024
2 parents 2b76416 + eddcfbe commit d235e94
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions pixeldata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ pub enum VoiLutOption {
First,
/// Apply a custom window level instead of the one described in the object.
Custom(WindowLevel),
/// Apply a custom window level and a custom function instead of the one described in the object.
CustomWithFunction(WindowLevel, VoiLutFunction),
/// Perform a min-max normalization instead,
/// so that the lowest value is 0 and
/// the highest value is the maximum value of the target type.
Expand Down Expand Up @@ -977,6 +979,15 @@ impl DecodedPixelData<'_> {
),
)
.context(CreateLutSnafu)?,
(VoiLutOption::CustomWithFunction(window, function), _) => {
Lut::new_rescale_and_window(
8,
signed,
rescale,
WindowLevelTransform::new(*function, *window),
)
.context(CreateLutSnafu)?
}
(VoiLutOption::Normalize, _) => Lut::new_rescale_and_normalize(
8,
signed,
Expand Down Expand Up @@ -1116,6 +1127,14 @@ impl DecodedPixelData<'_> {
*window,
),
),
(VoiLutOption::CustomWithFunction(window, function), _) => {
Lut::new_rescale_and_window(
self.bits_stored,
signed,
rescale,
WindowLevelTransform::new(*function, *window),
)
}
(VoiLutOption::Normalize, _) => Lut::new_rescale_and_normalize(
self.bits_stored,
signed,
Expand Down Expand Up @@ -1377,6 +1396,14 @@ impl DecodedPixelData<'_> {
*window,
),
),
(VoiLutOption::CustomWithFunction(window, function), _) => {
Lut::new_rescale_and_window(
8,
signed,
rescale,
WindowLevelTransform::new(*function, *window),
)
}
(VoiLutOption::Normalize, _) => Lut::new_rescale_and_normalize(
8,
signed,
Expand Down Expand Up @@ -1484,6 +1511,14 @@ impl DecodedPixelData<'_> {
*window,
),
),
(VoiLutOption::CustomWithFunction(window, function), _) => {
Lut::new_rescale_and_window(
self.bits_stored,
signed,
rescale,
WindowLevelTransform::new(*function, *window),
)
}
(VoiLutOption::Normalize, _) => Lut::new_rescale_and_normalize(
self.bits_stored,
signed,
Expand Down

0 comments on commit d235e94

Please sign in to comment.