View source on GitHub
|
Normalizes the image to zero mean and unit variance.
tfm.vision.preprocess_ops.normalize_image(
image: tf.Tensor,
offset: Sequence[float] = tfm.vision.preprocess_ops.MEAN_NORM,
scale: Sequence[float] = tfm.vision.preprocess_ops.STDDEV_NORM
) -> tf.Tensor
This function normalizes the input image by subtracting the offset
and dividing by the scale.
Important Note about Input Types and Normalization:
Integer Images: If the input
imageis an integer type (e.g.,uint8), the providedoffsetandscalevalues should be already normalized to the range [0, 1]. This is because the function converts integer images to float32 with values in the range [0, 1] before the normalization happens.Float Images: If the input
imageis a float type (e.g.,float32), theoffsetandscalevalues should be in the same range as the image data.- If the image has values in [0, 1], the
offsetandscaleshould also be in [0, 1]. - If the image has values in [0, 255], the
offsetandscaleshould also be in [0, 255].
- If the image has values in [0, 1], the
Args | |
|---|---|
image
|
A tf.Tensor in either:
(1) float dtype with values in range [0, 1) or [0, 255], or
(2) int type with values in range [0, 255].
|
offset
|
A tuple of mean values to be subtracted from the image. |
scale
|
A tuple of normalization factors. |
Returns | |
|---|---|
| A normalized image tensor. |
View source on GitHub