可以调用Ski-Image包的相关方法

compare_mse

skimage.measure.compare_mse(im1, im2)[source]
Compute the mean-squared error between two images.

Parameters:

im1, im2 : ndarray

Image. Any dimensionality.

Returns:

mse : float

The mean-squared error (MSE) metric.

compare_nrmse

skimage.measure.compare_nrmse(im_true, im_test, norm_type='Euclidean')[source]
Compute the normalized root mean-squared error (NRMSE) between two images.

Parameters:

im_true : ndarray

Ground-truth image.

im_test : ndarray

Test image.

norm_type : {‘Euclidean’, ‘min-max’, ‘mean’}

Controls the normalization method to use in the denominator of the NRMSE. There is no standard method of normalization across the literature [R330]. The methods available here are as follows:

  • ‘Euclidean’ : normalize by the Euclidean norm of im_true.
  • ‘min-max’ : normalize by the intensity range of im_true.
  • ‘mean’ : normalize by the mean of im_true.
Returns:

nrmse : float

The NRMSE metric.

References

[R330] (1, 2) https://en.wikipedia.org/wiki/Root-mean-square_deviation

compare_psnr

skimage.measure.compare_psnr(im_true, im_test, data_range=None, dynamic_range=None)[source]
Compute the peak signal to noise ratio (PSNR) for an image.

Parameters:

im_true : ndarray

Ground-truth image.

im_test : ndarray

Test image.

data_range : int

The data range of the input image (distance between minimum and maximum possible values). By default, this is estimated from the image data-type.

Returns:

psnr : float

The PSNR metric.

References

[R331] https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio

compare_ssim

skimage.measure.compare_ssim(X, Y, win_size=None, gradient=False, data_range=None, multichannel=False, gaussian_weights=False, full=False, dynamic_range=None, **kwargs)[source]
Compute the mean structural similarity index between two images.

Parameters:

X, Y : ndarray

Image. Any dimensionality.

win_size : int or None

The side-length of the sliding window used in comparison. Must be an odd value. If gaussian_weights is True, this is ignored and the window size will depend on sigma.

gradient : bool, optional

If True, also return the gradient.

data_range : int, optional

The data range of the input image (distance between minimum and maximum possible values). By default, this is estimated from the image data-type.

multichannel : bool, optional

If True, treat the last dimension of the array as channels. Similarity calculations are done independently for each channel then averaged.

gaussian_weights : bool, optional

If True, each patch has its mean and variance spatially weighted by a normalized Gaussian kernel of width sigma=1.5.

full : bool, optional

If True, return the full structural similarity image instead of the mean value.

Returns:

mssim : float

The mean structural similarity over the image.

grad : ndarray

The gradient of the structural similarity index between X and Y [R333]. This is only returned if gradient is set to True.

S : ndarray

The full SSIM image. This is only returned if full is set to True.

Other Parameters:

use_sample_covariance : bool

if True, normalize covariances by N-1 rather than, N where N is the number of pixels within the sliding window.

K1 : float

algorithm parameter, K1 (small constant, see [R332])

K2 : float

algorithm parameter, K2 (small constant, see [R332])

sigma : float

sigma for the Gaussian when gaussian_weights is True.

Notes

To match the implementation of Wang et. al. [R332], set gaussian_weights to True, sigma to 1.5, and use_sample_covariance to False.

References

[R332] (1, 2, 3, 4) Wang, Z., Bovik, A. C., Sheikh, H. R., & Simoncelli, E. P. (2004). Image quality assessment: From error visibility to structural similarity. IEEE Transactions on Image Processing, 13, 600-612.https://ece.uwaterloo.ca/~z70wang/publications/ssim.pdf, DOI:10.1.1.11.2477
[R333] (1, 2) Avanaki, A. N. (2009). Exact global histogram specification optimized for structural similarity. Optical Review, 16, 613-621.http://arxiv.org/abs/0901.0065, DOI:10.1007/s10043-009-0119-z