msi2slstr.transform.normalization

Data normalization module.

Classes

Normalizer(offset, scale, *[, e])

Class to normalize given array according to the normalizer state, always in a channelwise manner.

Standardizer([dims, e])

Class to standardize given array in a channelwise manner.

class msi2slstr.transform.normalization.Normalizer(offset: tuple[float], scale: tuple[float], *, e: float = 1e-15)[source]

Bases: object

Class to normalize given array according to the normalizer state, always in a channelwise manner. i.e. Each channel (dim 1) of the array is normalized independently.

\[A_{\mathrm{normal}} = \frac{(A - offset)} {(scale + \varepsilon)}\]
Parameters:
  • offset (tuple[float]) – A tuple of floats with the per channel value by which to offset the provided array’s value range. Has to be broadcastable to the array’s shape.

  • scale (tuple[int]) – A tuple of floats with the per channel value to scale the array’s value range. Has to be broadcastable to the array’s shape.

  • e (float, optional) – A small constant added to the denominator to avoid division by 0, defaults to 1e-15.

__call__(array: ndarray) ndarray[source]

Execute normalization.

Parameters:
  • array – Array to rescale according to offset and scale.

  • typendarray

Returns:

Normalized array with rescaled values.

Return type:

ndarray

reverse(array: ndarray) ndarray[source]

Reverse the value normalization.

Parameters:
  • array – Scaled array whose values to unscale.

  • typendarray

Returns:

Array with original values.

Return type:

ndarray

class msi2slstr.transform.normalization.Standardizer(dims: tuple[int] = None, *, e: float = 1e-15)[source]

Bases: object

Class to standardize given array in a channelwise manner.

\[A_{\mathrm{standard}} = \frac{(A - \bar{A})}{(\sigma_A + \varepsilon)}\]
Parameters:
  • dims (tuple[int], optional) – A tuple of ints indicating the dimensions to collapse.

  • e (float, optional) – A small constant added to the denominator to avoid division by 0, defauts to 1e-15.

__call__(array: ndarray) ndarray[source]

Execute standardization.

Parameters:
  • array – Array to rescale to have mean 0 and variance 1.

  • typendarray

Returns:

Standardized array.

Return type:

ndarray