viqa.fr_metrics.ssim.SSIM¶
- class viqa.fr_metrics.ssim.SSIM(data_range=255, normalize=False, **kwargs)[source]¶
Calculate the structural similarity index (SSIM) between two images.
- score_val¶
Score value of the SSIM metric.
- Type:
float or None
- parameters¶
Dictionary containing the parameters for SSIM calculation.
- Type:
dict
- Parameters:
data_range ({1, 255, 65535}, optional) – Data range of the returned data in data loading. Is used for image loading when
normalizeis True and for the SSIM calculation. Passed toviqa.utils.load_data()andviqa.fr_metrics.ssim.structural_similarity().normalize (bool, default False) – If True, the input images are normalized to the
data_rangeargument.**kwargs (optional) – Additional parameters for data loading. The keyword arguments are passed to
viqa.utils.load_data().chromatic (bool, default False) – If True, the input images are expected to be RGB images. If False, the input images are converted to grayscale images if necessary.
- Raises:
ValueError – If
data_rangeis not set.
Notes
data_rangefor image loading is also used for the SSIM calculation if the image type is integer and therefore must be set. The parameter is set through the constructor of the class and is passed to__call__(). SSIM [1] is a full-reference IQA metric. It is based on the human visual system and is designed to predict the perceived quality of an image.See also
viqa.fr_metrics.uqi.UQIUniversal quality index.
viqa.fr_metrics.msssim.MSSSIMMulti-scale structural similarity index.
References
- print_score(decimals=2)[source]¶
Print the SSIM score value of the last calculation.
- Parameters:
decimals (int, default=2) – Number of decimal places to print the score value.
- Warns:
RuntimeWarning – If
score_valis not available.
- export_results(path, filename)¶
Export the score to a csv file.
- Parameters:
path (str) – The path where the csv file should be saved.
filename (str) – The name of the csv file.
Notes
The arguments get passed to
viqa.utils.export_results().
- load_images(img_r, img_m)¶
Load the images and perform checks.
- Parameters:
img_r (np.ndarray, viqa.ImageArray, torch.Tensor, str or os.PathLike) – The reference image.
img_m (np.ndarray, viqa.ImageArray, torch.Tensor, str or os.PathLike) – The modified image.
- Returns:
img_r (viqa.ImageArray) – The loaded reference image as an
viqa.utils.ImageArray.img_m (viqa.ImageArray) – The loaded modified image as an
viqa.utils.ImageArray.
- score(*args, **kwargs)¶
Calculate the score.
Deprecated since version 3.0.0: Call the metric directly instead, e.g.
metric(img_m, img_r).scorewill be removed in the future. For full-reference metrics.