docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class PeakSignalToNoiseRatio

    Implements the Peak Signal-to-Noise Ratio (PSNR) metric for texture/image comparison. PSNR (in dB) is derived from the mean squared error (MSE) between a reference and a test image and depends on the peak pixel value (e.g., 255 for 8‑bit images). PSNR is commonly used to evaluate the fidelity of compressed images/video: higher values generally indicate better quality. Typical PSNR values for lossy compression often fall in the 30–50 dB range, though this depends on content, bit depth, resolution, and viewing conditions. Distortions are more likely to be perceptible below ~30–35 dB, while values above ~40 dB are often considered high quality. PSNR is a simple, non-perceptual metric; for perceptual assessment it should be complemented with other measures such as SSIM or color-difference metrics (e.g. DeltaE).

    Inheritance
    object
    TextureComparisonAlgorithm
    PeakSignalToNoiseRatio
    Inherited Members
    TextureComparisonAlgorithm.Settings
    TextureComparisonAlgorithm.Description
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.TestTools.Graphics
    Assembly: UnityEngine.TestTools.Graphics.dll
    Syntax
    public class PeakSignalToNoiseRatio : TextureComparisonAlgorithm

    Constructors

    PeakSignalToNoiseRatio(ITextureComparisonSettings)

    Initialized a new instance of the Peak Signal to Noise Ratio (PSNR) algorithm with the given threshold.

    Declaration
    public PeakSignalToNoiseRatio(ITextureComparisonSettings settings)
    Parameters
    Type Name Description
    ITextureComparisonSettings settings

    Ratio under which the test constraint fails

    Methods

    Compare(Texture2D, Texture2D)

    Compares two Texture2D and returns a Peak Signal to Noise Ratio.

    Declaration
    public override ITextureComparisonResult Compare(Texture2D expected, Texture2D actual)
    Parameters
    Type Name Description
    Texture2D expected

    The reference texture

    Texture2D actual

    The texture being evaluated

    Returns
    Type Description
    ITextureComparisonResult

    The Peak Signal To Noise Ratio. higher being better, 30 being the human perceptible threshold.

    Overrides
    TextureComparisonAlgorithm.Compare(Texture2D, Texture2D)

    Compare(Texture2D[], Texture2D[])

    Compares two arrays of textures using the Peak Signal to Noise Ratio (PSNR) algorithm. Both arrays need to have the same length and are compared by corresponding index.

    Declaration
    public override ITextureComparisonResult Compare(Texture2D[] expectedTextures, Texture2D[] actualTextures)
    Parameters
    Type Name Description
    Texture2D[] expectedTextures

    The reference textures

    Texture2D[] actualTextures

    The texture being evaluated

    Returns
    Type Description
    ITextureComparisonResult

    The Peak Signal To Noise Ratio. higher being better, 30 being the human perceptible threshold.

    Overrides
    TextureComparisonAlgorithm.Compare(Texture2D[], Texture2D[])

    CompareAsync(Texture2D, Texture2D)

    Compares asynchronously two textures using the Peak Signal to Noise Ratio (PSNR) algorithm.

    Declaration
    public override Task<ITextureComparisonResult> CompareAsync(Texture2D expected, Texture2D actual)
    Parameters
    Type Name Description
    Texture2D expected

    The reference image

    Texture2D actual

    The texture being evaluated against the reference

    Returns
    Type Description
    Task<ITextureComparisonResult>

    A task with a result

    Overrides
    TextureComparisonAlgorithm.CompareAsync(Texture2D, Texture2D)
    Exceptions
    Type Condition
    NotSupportedException

    Async comparison is not supported for this algorithm

    Evaluate(ITextureComparisonResult)

    Evaluates the comparison result against the defined threshold.

    Declaration
    public override (object, bool) Evaluate(ITextureComparisonResult result)
    Parameters
    Type Name Description
    ITextureComparisonResult result

    The PSNR comparison result

    Returns
    Type Description
    (object, bool)

    A tuple containing the result and whether it passes the evaluation

    Overrides
    TextureComparisonAlgorithm.Evaluate(ITextureComparisonResult)
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)