bundles / skimage latest / skimage / metrics / _structural_similarity / structural_similarity
function
skimage.metrics._structural_similarity:structural_similarity
source: /dev/scikit-image/src/skimage/metrics/_structural_similarity.py:13
Signature
def structural_similarity(im1, im2, *, win_size = None, gradient = False, data_range = None, channel_axis = None, gaussian_weights = False, full = False, **kwargs)Summary
Compute the mean structural similarity index between two images. Please pay attention to the data_range parameter with floating-point images.
Parameters
im1, im2: ndarrayImages. Any dimensionality with same shape.
win_size: int or None, optionalThe side-length of the sliding window used in comparisons (default: 7). Must be an odd value. If
gaussian_weightsis True,win_sizecannot be specified since the window size is determined by sigma.gradient: bool, optionalIf True, also return the gradient with respect to im2.
data_range: float, optionalThe data range of the input image (difference between maximum and minimum possible values). By default, this is estimated from the image data type. This estimate may be wrong for floating-point image data. Therefore it is recommended to always pass this scalar value explicitly (see note below).
channel_axis: int or None, optionalIf None, the image is assumed to be a grayscale (single channel) image. Otherwise, this parameter indicates which axis of the array corresponds to channels.
gaussian_weights: bool, optionalIf True, the local mean and variance are computed using a normalized Gaussian kernel of width sigma rather than a uniform window.
full: bool, optionalIf True, also return the full structural similarity image.
Returns
mssim: floatThe mean structural similarity index over the image.
grad: ndarrayThe gradient of the structural similarity between im1 and im2 [2]. This is only returned if
gradientis set to True.S: ndarrayThe full SSIM image. This is only returned if
fullis set to True.
Other Parameters
use_sample_covariance: boolIf True, normalize covariances by N-1 rather than, N where N is the number of pixels within the sliding window.
K1: floatAlgorithm parameter, K1 (small constant, see [1]).
K2: floatAlgorithm parameter, K2 (small constant, see [1]).
sigma: floatStandard deviation for the Gaussian when
gaussian_weightsis True. Default is 1.5.
Notes
If data_range is not specified, the range is automatically guessed based on the image data type. However for floating-point image data, this estimate yields a result double the value of the desired range, as the dtype_range in skimage.util.dtype.py has defined intervals from -1 to +1. This yields an estimate of 2, instead of 1, which is most often required when working with image data (as negative light intensities are nonsensical). In case of working with YCbCr-like color data, note that these ranges are different per channel (Cb and Cr have double the range of Y), so one cannot calculate a channel-averaged SSIM with a single call to this function, as identical ranges are assumed for each channel.
To match the implementation of Wang et al. [1], set gaussian_weights to True, sigma to 1.5, use_sample_covariance to False, and specify the data_range argument.
Aliases
skimage.metrics.structural_similarity