pysparse.evaluation package

Submodules

pysparse.evaluation.error module

pysparse.evaluation.error.mse(o, r)[source]

Mean Squared Error

The Mean Squared Error (MSE) is expressed as

\[{\rm MSE} = \frac{1}{MN}\sum_{i=1}^{M}\sum_{j=0}^{N}[{\bm I}(i,j), \hat{\bm I}(i, j)]^2 \]
Parameters:
  • o (ndarray) – Orignal signal matrix.
  • r (ndarray) – Reconstructed signal matrix
Returns:

MSE – Mean Squared Error

Return type:

float

pysparse.evaluation.error.rmse(o, r)[source]

Root Mean Squared Error

The Root Mean Squared Error (MSE) is expressed as

\[{\rm RMSE} = \sqrt{\frac{1}{MN}\sum_{i=1}^{M}\sum_{j=0}^{N}[{\bm I}(i,j), \hat{\bm I}(i, j)]^2} \]
Parameters:
  • o (ndarray) – Orignal signal matrix.
  • r (ndarray) – Reconstructed signal matrix
Returns:

RMSE – Root Mean Squared Error

Return type:

float

pysparse.evaluation.snr module

pysparse.evaluation.snr.psnr(o, r, Vpeak=None, mode='simple')[source]

Peak Signal-to-Noise Ratio

The Peak Signal-to-Noise Ratio (PSNR) is expressed as

\[{\rm PSNR} = 10 \log10(\frac{V_{peak}^2}{\rm MSE}) \]

For float data, \(V_{peak} = 1\);

For interges, \(V_{peak} = 2^{nbits}\), e.g. uint8: 255, uint16: 65535 …

Parameters:
  • o (array_like) – Reference data array. For image, it’s the original image.
  • r (array_like) – The data to be compared. For image, it’s the reconstructed image.
  • Vpeak (float, int or None, optional) – The peak value. If None, computes automaticly.
  • mode (str or None, optional) – ‘simple’ or ‘rich’. ‘simple’ (default) –> just return psnr i.e. ‘rich’ –> return psnr, mse, Vpeak, imgtype.
Returns:

PSNR – Peak Signal to Noise Ratio value.

Return type:

float

pysparse.evaluation.snr.snr()[source]

Module contents