예제 #1
0
        /// <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;
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
        /// <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;
        }
예제 #4
0
        /// <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);
        }
예제 #5
0
        public override AssessResult Assess(System.Drawing.Bitmap reference, System.Drawing.Bitmap distorted, UseComponent component)
        {
            double       Max        = 255;
            var          mseCalc    = new Mse();
            AssessResult mseResult  = mseCalc.Assess(reference, distorted, UseComponent.Luma | UseComponent.Cb | UseComponent.Cr);
            double       mse        = (mseResult.Luma + mseResult.Cb + mseResult.Cr) / 3;
            double       psnr       = 20 * Math.Log10(Max) - 10 * Math.Log10(mse);
            var          psnrResult = new AssessResult();

            psnrResult.Luma = psnr;
            psnrResult.Cb   = psnr;
            psnrResult.Cr   = psnr;
            return(psnrResult);
        }
예제 #6
0
        public override AssessResult Assess(System.Drawing.Bitmap reference, System.Drawing.Bitmap distorted, UseComponent component)
        {
            var result = new AssessResult();

            InitBitmaps(reference, distorted);

            // MSE
            double sum = 0.0;

            for (int i = 0; i < LumaReference.GetLength(0); i++)
            {
                for (int j = 0; j < LumaReference.GetLength(1); j++)
                {
                    sum += (LumaReference[i, j] - LumaDistorted[i, j]) * (LumaReference[i, j] - LumaDistorted[i, j]);
                }
            }
            result.Luma = sum / LumaReference.Length;

            sum = 0.0;
            for (int i = 0; i < CbReference.GetLength(0); i++)
            {
                for (int j = 0; j < CbReference.GetLength(1); j++)
                {
                    sum += (CbReference[i, j] - CbDistorted[i, j]) * (CbReference[i, j] - CbDistorted[i, j]);
                }
            }
            result.Cb = sum / CbReference.Length;

            sum = 0.0;
            for (int i = 0; i < CrReference.GetLength(0); i++)
            {
                for (int j = 0; j < CrReference.GetLength(1); j++)
                {
                    sum += (CrReference[i, j] - CrDistorted[i, j]) * (CrReference[i, j] - CrDistorted[i, j]);
                }
            }
            result.Cr = sum / CrReference.Length;

            return(result);
        }
예제 #7
0
 /// <summary>
 /// Assess the quality 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 bitmaps don't fit the assess precondition of the specified index.</exception>
 /// <returns>A new AssessResult object indicates the assess results in every specified component.</returns>
 public abstract AssessResult Assess(Bitmap reference, Bitmap distorted, UseComponent component);
 /// <summary>
 /// Assess the quality 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 bitmaps don't fit the assess precondition of the specified index.</exception>
 /// <returns>A new AssessResult object indicates the assess results in every specified component.</returns> 
 public abstract AssessResult Assess(Bitmap reference, Bitmap distorted, UseComponent component);