ImageComparisonSettings Class

Configures the comparison behavior used by ImageComparer. The thresholds apply to every frame; they use ImageSimilarity.

public sealed class ImageComparisonSettings

Constructors

NameDescription
ImageComparisonSettings()

ImageComparisonSettings()

public ImageComparisonSettings()

No documentation is available.

Properties

NameDescription
ButteraugliThresholdGets or sets the maximum Butteraugli distance for two images to be considered equal: 0 for identical images, below about 1 when the difference is not visible. When null, Butteraugli comparison is not performed.
DHashThresholdGets or sets the maximum distance between the 64-bit difference hashes (dHash) for two images to be considered equal. Values range from 0 (identical hashes) to 64. When null, dHash comparison is not performed.
PHashThresholdGets or sets the maximum distance between the 64-bit perceptual hashes (pHash) for two images to be considered equal. Values range from 0 (identical hashes) to 64. When null, pHash comparison is not performed.
PsnrThresholdGets or sets the minimum peak signal-to-noise ratio (PSNR), in decibels, required for two images to be considered equal. Identical images have an infinite ratio; lossy encodings are typically between 30 and 50. When null, PSNR comparison is not performed.
SimilarityThresholdGets or sets the minimum Structural Similarity Index (SSIM) score required for two images to be considered equal. Values range from 0.0 to 1.0 (identical). When all thresholds are null, exact pixel comparison is used.
Ssimulacra2ThresholdGets or sets the minimum SSIMULACRA 2 score required for two images to be considered equal. Scores go up to 100 (identical); about 90 means the difference is not visible, 70 a high quality. When null, SSIMULACRA 2 comparison is not performed.

ButteraugliThreshold

ImageComparisonSettings.cs

Gets or sets the maximum Butteraugli distance for two images to be considered equal: 0 for identical images, below about 1 when the difference is not visible. When null, Butteraugli comparison is not performed.

public double? ButteraugliThreshold { get; set; }

Property value

double?

Exceptions

ArgumentOutOfRangeException
The value is negative, infinite or not a number.

Remarks

The distance is the largest value of the Butteraugli map of libjxl (ButteraugliDistance.MaxDistance), a psychovisual model that gives a distance for every pixel: unlike the SSIM and PSNR means, a difference confined to a small area weighs fully. Images that are not fully opaque are composited over black and over white, and every pixel keeps the larger distance. It is the slowest check. Images must have the same dimensions.

Gets or sets the maximum distance between the 64-bit difference hashes (dHash) for two images to be considered equal. Values range from 0 (identical hashes) to 64. When null, dHash comparison is not performed.

public int? DHashThreshold { get; set; }

Property value

int?

Remarks

The distance is the Hamming distance between the hashes, plus the difference between the mean luminances of the images on the same scale (a solid black and a solid white image are 64 apart; each unit is about 4 luminance levels out of 255), capped at 64. A bit is set only when the left thumbnail cell is brighter than the right one by more than half a luminance level, so invisible noise in flat areas does not flip bits. Images that are not fully opaque are compared composited over a black and over a white background, and the larger distance is used. Images must have the same dimensions.

Gets or sets the maximum distance between the 64-bit perceptual hashes (pHash) for two images to be considered equal. Values range from 0 (identical hashes) to 64. When null, pHash comparison is not performed.

public int? PHashThreshold { get; set; }

Property value

int?

Remarks

The distance is computed like the one used by ImageComparisonSettings.DHashThreshold. A bit is set only when its DCT coefficient exceeds the median coefficient by more than one luminance level, so invisible noise in flat areas does not flip bits.

Gets or sets the minimum peak signal-to-noise ratio (PSNR), in decibels, required for two images to be considered equal. Identical images have an infinite ratio; lossy encodings are typically between 30 and 50. When null, PSNR comparison is not performed.

public double? PsnrThreshold { get; set; }

Property value

double?

Exceptions

ArgumentOutOfRangeException
The value is negative or not a number.

Remarks

The ratio is computed from the mean squared error of the R, G and B channels premultiplied by alpha, the value scikit-image's peak_signal_noise_ratio(expected, actual, data_range=255) computes for opaque images. The alpha channel gives its own ratio, and the lower of the two is used. Like SSIM, it is a mean: a localized difference lowers it less than the same difference spread over the image. Images must have the same dimensions.

SimilarityThreshold

ImageComparisonSettings.cs

Gets or sets the minimum Structural Similarity Index (SSIM) score required for two images to be considered equal. Values range from 0.0 to 1.0 (identical). When all thresholds are null, exact pixel comparison is used.

public float? SimilarityThreshold { get; set; }

Property value

float?

Exceptions

ArgumentOutOfRangeException
The value is not between 0.0 and 1.0.

Remarks

The score is the mean SSIM over every 7×7 window of the images (uniform weights, sample covariance, K1 = 0.01, K2 = 0.03), the value scikit-image's structural_similarity computes with its default parameters. The R, G and B channels are premultiplied by the alpha channel and averaged, and the result is the lower of that score and the score of the alpha channel. Because the score is a mean, a localized difference lowers it in proportion to the area it covers: a difference confined to 1% of the image lowers it by about 0.01 at most. Images must have the same dimensions.

Ssimulacra2Threshold

ImageComparisonSettings.cs

Gets or sets the minimum SSIMULACRA 2 score required for two images to be considered equal. Scores go up to 100 (identical); about 90 means the difference is not visible, 70 a high quality. When null, SSIMULACRA 2 comparison is not performed.

public double? Ssimulacra2Threshold { get; set; }

Property value

double?

Exceptions

ArgumentOutOfRangeException
The value is greater than 100, infinite or not a number.

Remarks

The score is the one of the ssimulacra2 tool of libjxl, a perceptual metric that compares the images in the XYB color space at 6 scales and penalizes new artifacts (ringing, banding, blockiness) and lost details (blurring). Images that are not fully opaque are composited over a dark and a bright gray, and the lower score is used. The metric needs images of at least 8×8 pixels: smaller images pass this check only when their pixels are identical (fully transparent pixels are equal whatever color they hide). Images must have the same dimensions.