Skip to content

Intensity transforms

intensity_transforms #

ClipIntensity dataclass #

ClipIntensity(lower: float, upper: float)

Bases: imgtools.transforms.intensity_transforms.IntensityTransform

ClipIntensity operation class.

A callable class that clips image grey level intensities to specified range.

Parameters:

Name Type Description Default

lower #

float

The lower bound on grey level intensity. Voxels with lower intensity will be set to this value.

required

upper #

float

The upper bound on grey level intensity. Voxels with higer intensity will be set to this value.

required

Methods:

Name Description
supports_reference

Return whether this transform supports reference images.

name property #

name: str

Return the name of the transform class for logging and debugging.

Returns:

Type Description
str

The name of the transform class.

supports_reference #

supports_reference() -> bool

Return whether this transform supports reference images.

Returns:

Type Description
bool

Always False for intensity transforms.

Source code in src/imgtools/transforms/intensity_transforms.py
def supports_reference(self) -> bool:
    """Return whether this transform supports reference images.

    Returns
    -------
    bool
        Always False for intensity transforms.
    """
    return False

IntensityTransform #

Bases: imgtools.transforms.base_transform.BaseTransform

Base class for intensity transforms.

Intensity transforms modify the pixel/voxel intensity values of an image without changing its spatial properties.

All intensity transforms operate on individual pixel/voxel values independently, leaving the image dimensions, spacing, and orientation unchanged.

Examples:

>>> # This is an abstract base class and cannot be instantiated directly.
>>> # Use one of its subclasses like ClipIntensity or WindowIntensity.

Methods:

Name Description
supports_reference

Return whether this transform supports reference images.

name property #

name: str

Return the name of the transform class for logging and debugging.

Returns:

Type Description
str

The name of the transform class.

supports_reference #

supports_reference() -> bool

Return whether this transform supports reference images.

Returns:

Type Description
bool

Always False for intensity transforms.

Source code in src/imgtools/transforms/intensity_transforms.py
def supports_reference(self) -> bool:
    """Return whether this transform supports reference images.

    Returns
    -------
    bool
        Always False for intensity transforms.
    """
    return False

WindowIntensity dataclass #

WindowIntensity(window: float, level: float)

Bases: imgtools.transforms.intensity_transforms.IntensityTransform

WindowIntensity operation class.

A callable class that restricts image grey level intensities to a given window and level. This is commonly used in medical imaging to enhance visibility of specific tissue types (e.g., bone window, lung window in CT).

The window/level parameters define a range centered at the 'level' value with a width of 'window'. All intensities outside this range are clipped.

Parameters:

Name Type Description Default

window #

float

The width of the intensity window. Must be positive.

required

level #

float

The mid-point of the intensity window.

required

Methods:

Name Description
supports_reference

Return whether this transform supports reference images.

name property #

name: str

Return the name of the transform class for logging and debugging.

Returns:

Type Description
str

The name of the transform class.

supports_reference #

supports_reference() -> bool

Return whether this transform supports reference images.

Returns:

Type Description
bool

Always False for intensity transforms.

Source code in src/imgtools/transforms/intensity_transforms.py
def supports_reference(self) -> bool:
    """Return whether this transform supports reference images.

    Returns
    -------
    bool
        Always False for intensity transforms.
    """
    return False