def _compute_msssim(imQual, nlevels=5, sigma=1.2, L=1, K=(0.01, 0.03)):
'''
An implementation of the Multi-Scale Structural SIMilarity index (MS-SSIM).
References
-------------
Multi-scale Structural Similarity Index (MS-SSIM)
Z. Wang, E. P. Simoncelli and A. C. Bovik, "Multi-scale structural
similarity for image quality assessment," Invited Paper, IEEE Asilomar
Conference on Signals, Systems and Computers, Nov. 2003
Parameters
-------------
imQual : ImageQuality
nlevels : int
The max number of levels to analyze
sigma : float
Sets the standard deviation of the gaussian filter. This setting
determines the minimum scale at which quality is assessed.
L : scalar
The dynamic range of the data. This value is 1 for float
representations and 2^bitdepth for integer representations.
K : 2-tuple
A list of two constants which help prevent division by zero.
Returns
-------
imQual : ImageQuality
A struct used to organize image quality information. NOTE: the valid
range for SSIM is [-1, 1].
'''
_full_reference_input_check(imQual, sigma, nlevels, L)
img1 = imQual.orig
img2 = imQual.recon
# The relative imporance of each level as determined by human experiment
# weight = [0.0448, 0.2856, 0.3001, 0.2363, 0.1333]
for level in range(0, nlevels):
imQual += _compute_ssim(ImageQuality(img1, img2), sigma=sigma, L=L,
K=K, scale=sigma * 2**level)
if level == nlevels - 1:
break
# Downsample (using ndimage.zoom to prevent sampling bias)
img1 = scipy.ndimage.zoom(img1, 1/2)
img2 = scipy.ndimage.zoom(img2, 1/2)
return imQual
评论列表
文章目录