/// <summary> /// Assess Mean MS-SSIM of a distorted bitmap with the reference bitmap /// </summary> /// <param name="reference">Reference bitmap</param> /// <param name="distorted">Distorted bitmap</param> /// <param name="component">Specify which components will be assessed, multiple components can be set by using bitwise-or</param> /// <exception cref="ArgumentNullException">Thrown when at least one param is null</exception> /// <exception cref="ArgumentException">Thrown when the size of the two bitmaps are not illegal for assessment (Sizes are not same, Size too small, etc.)</exception> /// <returns>A new AssessResult object indicates the assess results in every specified component.</returns> public override AssessResult Assess(Bitmap reference, Bitmap distorted, UseComponent component) { InitBitmaps(reference, distorted); LumaReference = Downscaler.DownscaleByKeepMinLength(LumaReference, ScaleMinLength); LumaDistorted = Downscaler.DownscaleByKeepMinLength(LumaDistorted, ScaleMinLength); AssessResult res = new AssessResult(); if (component.HasFlag(UseComponent.Luma)) { res.Luma = GetComponentQuality(LumaReference, LumaDistorted); } if (component.HasFlag(UseComponent.Cb)) { res.Cb = GetComponentQuality(CbReference, CbDistorted); } if (component.HasFlag(UseComponent.Cr)) { res.Cr = GetComponentQuality(CrReference, CrDistorted); } return(res); }
/// <summary> /// Assess Mean G-SSIM of a distorted bitmap with the reference bitmap /// </summary> /// <param name="reference">Reference bitmap</param> /// <param name="distorted">Distorted bitmap</param> /// <param name="component">Specify which components will be assessed, multiple components can be set by using bitwise-or</param> /// <exception cref="ArgumentNullException">Thrown when at least one param is null</exception> /// <exception cref="ArgumentException">Thrown when the size of the two bitmaps are not illegal for assessment (Sizes are not same, Size too small, etc.)</exception> /// <returns>A new AssessResult object indicates the assess results in every specified component.</returns> public override AssessResult Assess(Bitmap reference, Bitmap distorted, UseComponent component) { InitBitmaps(reference, distorted); LumaReference = Downscaler.DownscaleByKeepMinLength(LumaReference, ScaleMinLength); LumaDistorted = Downscaler.DownscaleByKeepMinLength(LumaDistorted, ScaleMinLength); SsimParameters gssimParams = new SsimParameters(WindowWidth, WindowHeight, C1, C2, C3); GssimCalculator gssimCalc = new GssimCalculator(gssimParams); AssessResult res = new AssessResult(); if (component.HasFlag(UseComponent.Luma)) { res.Luma = gssimCalc.CalcMeanGssim(LumaReference, LumaDistorted); } if (component.HasFlag(UseComponent.Cb)) { res.Cb = gssimCalc.CalcMeanGssim(CbReference, CbDistorted); } if (component.HasFlag(UseComponent.Cr)) { res.Cr = gssimCalc.CalcMeanGssim(CrReference, CrDistorted); } return(res); }