# sporco.metric¶

Image quality metrics and related functions

Note that the well-known SSIM metric is not implemented here as it is available in a number of other Python packages, including:

Some implementations are also available in unpackaged collections of Python code:

Functions

 mae(vref, vcmp) Compute Mean Absolute Error (MAE) between two images. mse(vref, vcmp) Compute Mean Squared Error (MSE) between two images. snr(vref, vcmp) Compute Signal to Noise Ratio (SNR) of two images. psnr(vref, vcmp[, rng]) Compute Peak Signal to Noise Ratio (PSNR) of two images. isnr(vref, vdeg, vrst) Compute Improvement Signal to Noise Ratio (ISNR) for reference, degraded, and restored images. bsnr(vblr, vnsy) Compute Blurred Signal to Noise Ratio (BSNR) for a blurred and noisy image. pamse(vref, vcmp[, rescale]) Compute Perceptual-fidelity Aware Mean Squared Error (PAMSE) IQA metric [40]. gmsd(vref, vcmp[, rescale, returnMap]) Compute Gradient Magnitude Similarity Deviation (GMSD) IQA metric [41].

## Function Descriptions¶

sporco.metric.mae(vref, vcmp)[source]

Compute Mean Absolute Error (MAE) between two images.

Parameters: vref : array_like Reference image vcmp : array_like Comparison image x : float MAE between vref and vcmp
sporco.metric.mse(vref, vcmp)[source]

Compute Mean Squared Error (MSE) between two images.

Parameters: vref : array_like Reference image vcmp : array_like Comparison image x : float MSE between vref and vcmp
sporco.metric.snr(vref, vcmp)[source]

Compute Signal to Noise Ratio (SNR) of two images.

Parameters: vref : array_like Reference image vcmp : array_like Comparison image x : float SNR of vcmp with respect to vref
sporco.metric.psnr(vref, vcmp, rng=None)[source]

Compute Peak Signal to Noise Ratio (PSNR) of two images. The PSNR calculation defaults to using the less common definition in terms of the actual range (i.e. max minus min) of the reference signal instead of the maximum possible range for the data type (i.e. $$2^b-1$$ for a $$b$$ bit representation).

Parameters: vref : array_like Reference image vcmp : array_like Comparison image rng : None or int, optional (default None) Signal range, either the value to use (e.g. 255 for 8 bit samples) or None, in which case the actual range of the reference signal is used x : float PSNR of vcmp with respect to vref
sporco.metric.isnr(vref, vdeg, vrst)[source]

Compute Improvement Signal to Noise Ratio (ISNR) for reference, degraded, and restored images.

Parameters: vref : array_like Reference image vdeg : array_like Degraded image vrst : array_like Restored image x : float ISNR of vrst with respect to vref and vdeg
sporco.metric.bsnr(vblr, vnsy)[source]

Compute Blurred Signal to Noise Ratio (BSNR) for a blurred and noisy image.

Parameters: vblr : array_like Blurred noise free image vnsy : array_like Blurred image with additive noise x : float BSNR of vnsy with respect to vblr and vdeg
sporco.metric.pamse(vref, vcmp, rescale=True)[source]

Compute Perceptual-fidelity Aware Mean Squared Error (PAMSE) IQA metric [40]. This implementation is a translation of the reference Matlab implementation provided by the authors of [40].

Parameters: vref : array_like Reference image vcmp : array_like Comparison image rescale : bool, optional (default True) Rescale inputs so that vref has a maximum value of 255, as assumed by reference implementation score : float PAMSE IQA metric
sporco.metric.gmsd(vref, vcmp, rescale=True, returnMap=False)[source]

Compute Gradient Magnitude Similarity Deviation (GMSD) IQA metric [41]. This implementation is a translation of the reference Matlab implementation provided by the authors of [41].

Parameters: vref : array_like Reference image vcmp : array_like Comparison image rescale : bool, optional (default True) Rescale inputs so that vref has a maximum value of 255, as assumed by reference implementation returnMap : bool, optional (default False) Flag indicating whether quality map should be returned in addition to scalar score score : float GMSD IQA metric quality_map : ndarray Quality map