Applies linear window/level (Window Center and Window Width) transformation
to a DICOM pixel matrix or array, normalizing output values to [0, 1].
Supports standard clinical CT window presets ("brain", "lung", "bone",
"abdomen", "mediastinum", "liver", "stroke", "subdural", "angio"),
embedded DICOM WindowCenter/WindowWidth tags ("auto"), or custom
numeric center and width.
Arguments
- x
A
"dicom_pixels"array/matrix or a file path to a DICOM file.- center
Numeric window center (level). Overrides
presetif bothcenterandwidthare provided.- width
Numeric window width (must be
> 0).- preset
Character preset name (
"auto","brain","stroke","subdural","lung","mediastinum","abdomen","liver","bone","angio") or numeric vectorc(center, width). Default is"auto".- invert
Optional logical to invert grayscale intensities. By default, automatically inverts if
PhotometricInterpretation == "MONOCHROME1".
Examples
dcm_file <- system.file("extdata", "example.dcm", package = "dicomtk")
px <- read_dicom_pixels(dcm_file)
win_auto <- dicom_window(px, preset = "auto")
range(win_auto)
#> [1] 0 1
