cbi_toolbox.reconstruct

Submodules

Module contents

The reconstruct package provides reconstruction algorithms, as well as preprocessing tools and performance scores.

cbi_toolbox.reconstruct.mse(ref, target)[source]

Computes the Mean Squared Error between two arrays

Parameters
  • ref (numpy.ndarray) – Reference array.

  • target (numpy.ndarray) – Target array.

Returns

The MSE.

Return type

float

cbi_toolbox.reconstruct.normalize(image, mode='std')[source]

Normalize an image according to the given criterion.

Parameters
  • image (numpy.ndarray) – Image to normalize, will be modified.

  • mode (str, optional) – Type of normalization to use, by default ‘std’. Allowed: [‘std’, ‘max’, ‘sum’]

Returns

The normalized image (same as input).

Return type

array

Raises

ValueError – For unknown mode.

cbi_toolbox.reconstruct.psnr(ref, target, norm=None, limit=None)[source]

Computes the Peak Signal-to-Noise Ratio: PSNR = 10 log( limit ^ 2 / MSE(ref, target) )

Parameters
  • ref (numpy.ndarray) – The ground-truth reference array.

  • target (numpy.ndarray) – The reconstructed array.

  • norm (str) – Normalize the images before computing snr, default is None.

  • limit (float, optional) – The maximum pixel value used for PSNR computation, default is None (max(ref)).

Returns

The PSNR.

Return type

float

cbi_toolbox.reconstruct.scale_to_mse(ref, target)[source]

Scale a target array to minimise MSE with reference

Parameters
  • ref (numpy.ndarray) – The reference for MSE.

  • target (numpy.ndarray) – The array to rescale (will be done in-place).

Returns

The rescaled target.

Return type

numpy.ndarray