Skip to content

Normalize

Source

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:

Name Type Description Default
image_means list or tuple of float

Mean value per channel.

required
image_stds list or tuple of float

Standard deviation value per channel.

required

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:

Name Type Description Default
image_means list of float

Mean value per channel.

required
image_stds list of float

Standard deviation value per channel.

required
target_means list of float

Target mean value per channel, by default None.

None
target_stds list of float

Target standard deviation value per channel, by default None.

None

Attributes:

Name Type Description
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.

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:

Name Type Description Default
image_means list or tuple of float

Mean value per channel.

required
image_stds list or tuple of float

Standard deviation value per channel.

required