viqa.fr_metrics.mad.most_apparent_distortion

viqa.fr_metrics.mad.most_apparent_distortion(img_r: ndarray, img_m: ndarray, data_range: int = 255, block_size: int = 16, block_overlap: float = 0.75, beta_1: float = 0.467, beta_2: float = 0.13, thresh_1: float | None = None, thresh_2: float | None = None, **kwargs) float[source]

Calculate the most apparent distortion (MAD) between two images.

Parameters:
  • img_r (np.ndarray) – Reference image to calculate score against.

  • img_m (np.ndarray) – Distorted image to calculate score of.

  • data_range (int, default=255) – Data range of the input images.

  • block_size (int, default=16) – Size of the blocks in the MAD calculation. Must be positive. Use 1 for no blocks.

  • block_overlap (float, default=0.75) – Overlap of the blocks in the MAD calculation. Given as a fraction of block_size.

  • beta_1 (float, default=0.467) – Parameter for single metrics combination.

  • beta_2 (float, default=0.130) – Parameter for single metrics combination.

  • thresh_1 (float, optional) – Threshold for single metrics combination.

  • thresh_2 (float, optional) – Threshold for single metrics combination.

  • **kwargs (optional) – Additional parameters for MAD calculation.

  • account_monitor (bool, default False) – If True, the display_function of the monitor is taken into account.

  • display_function (dict, optional) –

    Parameters of the display function of the monitor. Must be given if account_monitor is True.

    Dictionary layout for display_function

    disp_res : float, Display resolution.

    view_dis : float, Viewing distance. Same unit as disp_res.

  • luminance_function (dict, optional) –

    Parameters of the luminance function. If not given, default values for sRGB displays are used.

    Dictionary layout for luminance_function

    b : float, default=0.0

    k : float, default=0.02874

    gamma : float, default=2.2

  • ms_scale (float, default=1) – Additional normalization parameter for the high-quality index.

  • orientations_num (int, default 4) – Number of orientations for the log-Gabor filters. Passed to .viqa.utils.gabor_convolve.

  • scales_num (int, default 5) – Number of scales for the log-Gabor filters. Passed to .viqa.utils.gabor_convolve.

  • weights (list, default [0.5, 0.75, 1, 5, 6]) – Weights for the different scales of the log-Gabor filters. Must be of length scales_num.

  • csf_function (dict, optional) –

    Parameters for the contrast sensitivity function. If not given, default values for sRGB displays are used.

    Dictionary layout for csf_function

    lambda_csf : float, default=0.114

    f_peak : float, default=7.8909

Returns:

mad_index – MAD score value.

Return type:

float

Raises:

ValueError – If block_size is larger than the image dimensions. If block_overlap is not between 0 and smaller than 1. If block_size is not positive. If weights is not of length scales_num.

Warns:

RuntimeWarning – If either thresh_1 or thresh_2 and not both are given.

If thresh_1 and thresh_2 and beta_1 or beta_2 are given.

Warning

The metric is not yet validated. Use with caution.

See also

viqa.fr_metrics.mad.most_apparent_distortion_3d

Calculate the MAD for a 3D image.

Notes

The metric is calculated as combination of two single metrics. One for high quality and one for low quality of the image. The parameters beta_1, beta_2, thresh_1 and thresh_2 determine the weighting of the two combined single metrics. If thresh_1 and thresh_2 are given, beta_1 and beta_2 are calculated from them, else beta_1 and beta_2 or their default values are used. The values to be set for thresh_1 and thresh_2 that lead to the default values beta_1=0.467 and beta_2=0.130 are thresh_1=2.55 and thresh_2=3.35. These need not to be set, since automatic values for beta_1 and beta_2 are used when they are not given as parameter. For more information see [1]. The code is adapted from the original MATLAB code available under [2].

References