menpo.feature.normalize(image, *args, **kwargs)[source]

Normalize the pixel values via mean centering and an optional scaling. By default the scaling will be 1.0. The mode parameter selects whether the normalisation is computed across all pixels in the image or per-channel.

  • img (Image or subclass or (C, X, Y, ..., Z) ndarray) – Either the image object itself or an array with the pixels. The first dimension is interpreted as channels. This means an N-dimensional image is represented by an N+1 dimensional array.
  • scale_func (callable, optional) – Compute the scaling factor. Expects a single parameter and an optional axis keyword argument and will be passed the entire pixel array. Should return a 1D numpy array of one or more values.
  • mode ({all, per_channel}, optional) – If all, the normalization is over all channels. If per_channel, each channel individually is mean centred and normalized in variance.
  • error_on_divide_by_zero (bool, optional) – If True, will raise a ValueError on dividing by zero. If False, will merely raise a warning and only those values with non-zero denominators will be normalized.

pixels (Image or subclass or (X, Y, ..., Z, C) ndarray) – A normalized copy of the image that was passed in.


ValueError – If any of the denominators are 0 and error_on_divide_by_zero is True.