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.mutual_information(sig_a, sig_b, bins=20)[source]

Compute the mutual information between two signals.

Parameters:
  • sig_a (numpy.ndarray) – The first signal

  • sig_b (numpy.ndarray) – The second signal

  • bins (int, optional) – The number of bins used for probability density estimation, by default 20

Returns:

The mutual information

Return type:

float

cbi_toolbox.reconstruct.normalize(image, mode='std', in_place=False)[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’]

  • in_place (bool, optional) – Perform computations in-place, by default False.

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, in_place=False)[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)).

  • in_place (bool, optional) – Perform normalizations in-place, by default False.

Returns:

The PSNR.

Return type:

float

cbi_toolbox.reconstruct.scale_to_mse(ref, target, in_place=False)[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.

  • in_place (bool, optional) – Perform computations in-place, by default False.

Returns:

The rescaled target.

Return type:

numpy.ndarray