Range Normalization
Range (min-max) normalization for image patches.
RangeNormalization
Bases: Normalization
Normalize an image or image patch to [0, 1] range.
This transform expects C(Z)YX dimensions for normalization and BC(Z)YX for denormalization. Returns float32 arrays.
Parameters:
-
input_mins(list of float) –Minimum value per channel.
-
input_maxes(list of float) –Maximum value per channel.
-
target_mins(list of float, default:None) –Target minimum value per channel.
-
target_maxes(list of float, default:None) –Target maximum value per channel.
-
skip_target(bool, default:False) –When True, target normalization is skipped and the target is returned unchanged.
Attributes:
-
input_mins(list of float) –Minimum value per channel.
-
input_maxes(list of float) –Maximum value per channel.
-
target_mins(list of float, optional) –Target minimum value per channel.
-
target_maxes(list of float, optional) –Target maximum value per channel.
-
skip_target(bool) –When True, target normalization is skipped and the target is returned unchanged.
__call__(patch, target=None)
Apply range normalization to patch and optional target.
Parameters:
-
patch(NDArray) –Patch with shape C(Z)YX.
-
target(NDArray, default:None) –Target patch with shape C(Z)YX.
Returns:
-
tuple of NDArray–Normalized patch and target (target can be None).
__init__(input_mins, input_maxes, target_mins=None, target_maxes=None, skip_target=False)
Initialize range normalization.
Parameters:
-
input_mins(list of float) –Minimum value per channel.
-
input_maxes(list of float) –Maximum value per channel.
-
target_mins(list of float or None, default:None) –Target minimum per channel.
-
target_maxes(list of float or None, default:None) –Target maximum per channel.
-
skip_target(bool, default:False) –When True, target normalization is skipped and the target is returned unchanged (as float32). Default is False.
denormalize(patch)
Reverse the normalization operation for a batch of patches.
The data is denormalized using the target range, when available. When no target range is available, which is the case for self-supervised algorithms such as N2V, the data is denormalized using the input range.
If self.skip_target is True, then this method returns patch.
Parameters:
-
patch(Tensor) –Normalized patch with shape BC(Z)YX.
Returns:
-
Tensor–Denormalized patch.