Normalize
Normalization and denormalization transforms for image patches.
Denormalize
Denormalize an image.
Denormalization is performed expecting a zero mean and unit variance input. This transform expects C(Z)YX dimensions.
Note that an epsilon value of 1e-6 is added to the standard deviation to avoid division by zero during the normalization step, which is taken into account during denormalization.
Parameters:
-
image_means(list or tuple of float) –Mean value per channel.
-
image_stds(list or tuple of float) –Standard deviation value per channel.
__call__(patch)
Reverse the normalization operation for a batch of patches.
Parameters:
-
patch(NDArray) –Patch, 2D or 3D, shape BC(Z)YX.
Returns:
-
NDArray–Transformed array.
__init__(image_means, image_stds)
Constructor.
Parameters:
-
image_means(list of float) –Mean value per channel.
-
image_stds(list of float) –Standard deviation value per channel.
Normalize
Bases: Transform
Normalize an image or image patch.
Normalization is a zero mean and unit variance. This transform expects C(Z)YX dimensions.
Not that an epsilon value of 1e-6 is added to the standard deviation to avoid division by zero and that it returns a float32 image.
Parameters:
-
image_means(list of float) –Mean value per channel.
-
image_stds(list of float) –Standard deviation value per channel.
-
target_means(list of float, default:None) –Target mean value per channel, by default None.
-
target_stds(list of float, default:None) –Target standard deviation value per channel, by default None.
Attributes:
-
image_means(list of float) –Mean value per channel.
-
image_stds(list of float) –Standard deviation value per channel.
-
target_means(list of float, optional) –Target mean value per channel, by default None.
-
target_stds(list of float, optional) –Target standard deviation value per channel, by default None.
__call__(patch, target=None, **additional_arrays)
Apply the transform to the source patch and the target (optional).
Parameters:
-
patch(NDArray) –Patch, 2D or 3D, shape C(Z)YX.
-
target(NDArray, default:None) –Target for the patch, by default None.
-
**additional_arrays(NDArray, default:{}) –Additional arrays that will be transformed identically to
patchandtarget.
Returns:
-
tuple of NDArray–Transformed patch and target, the target can be returned as
None.
__init__(image_means, image_stds, target_means=None, target_stds=None)
Constructor.
Parameters:
-
image_means(list of float) –Mean value per channel.
-
image_stds(list of float) –Standard deviation value per channel.
-
target_means(list of float, default:None) –Target mean value per channel, by default None.
-
target_stds(list of float, default:None) –Target standard deviation value per channel, by default None.
TrainDenormalize
Denormalize an image tensor for training-time tensors.
This class mirrors Denormalize but operates on torch tensors. It expects
the input tensor to have shape BC(Z)YX with the channel dimension at index 1.
Parameters:
-
image_means(list or tuple of float) –Mean value per channel.
-
image_stds(list or tuple of float) –Standard deviation value per channel.
__call__(patch)
Reverse the normalization operation for a batch of patches.
Parameters:
-
patch(Tensor) –Patch, 2D or 3D, shape BC(Z)YX.
Returns:
-
Tensor–Denormalized tensor with dtype float32.
__init__(image_means, image_stds)
Initialize Denormalize transform.
Parameters:
-
image_means(list of float) –Mean values per channel.
-
image_stds(list of float) –Standard deviation values per channel.