Ejemplo n.º 1
0
        public static double EvaluateLocallyWAbs(UnmanagedImage image)
        {
            byte[,] pixels = image.GetPixels();

            int width = pixels.GetLength(0);
            int height = pixels.GetLength(1);

            double aggregate = 0;

            for (int i = 0; i < width - 1; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    aggregate += Math.Abs((pixels[i, j] - pixels[i + 1, j]));
                }
            }

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height - 1; j++)
                {
                    aggregate += Math.Abs((pixels[i, j] - pixels[i, j + 1]));
                }
            }

            for (int i = 0; i < width - 1; i++)
            {
                for (int j = 0; j < height - 1; j++)
                {
                    aggregate += Math.Abs((pixels[i, j] - pixels[i + 1, j + 1]));
                }
            }

            for (int i = 0; i < width - 1; i++)
            {
                for (int j = 1; j < height; j++)
                {
                    aggregate += Math.Abs((pixels[i, j] - pixels[i + 1, j - 1]));
                }
            }

            return (1D / (width * height * Math.Pow(255, 2))) * aggregate;
        }
Ejemplo n.º 2
0
 public static double EvaluateM(UnmanagedImage image)
 {
     byte[,] pixels = image.GetPixels();
     var stats = new ImageStatistics(image);
     var minGrayLevel = (byte)stats.Gray.Min;
     var maxGrayLevel = (byte)stats.Gray.Max;
     return (double)(maxGrayLevel - minGrayLevel) / (double)(maxGrayLevel + minGrayLevel);
 }
Ejemplo n.º 3
0
        public static double EvaluateWAbs(UnmanagedImage image)
        {
            byte[,] pixels = image.GetPixels();
            double aggregate = 0;

            int width = pixels.GetLength(0);
            int height = pixels.GetLength(1);

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    aggregate += pixels[i, j];
                }
            }

            aggregate = Math.Pow(width * height, -1) * aggregate;

            double aggregate2 = 0;

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    aggregate2 += Math.Abs((pixels[i, j] - aggregate));
                }
            }

            return (4D / (width * height * Math.Pow(255, 2))) * aggregate2;
        }
Ejemplo n.º 4
0
        public static double EvaluateS(UnmanagedImage image)
        {
            byte[,] pixels = image.GetPixels();
            var stats = new ImageStatistics(image);
            var minGrayLevel = (byte)stats.Gray.Min;
            var maxGrayLevel = (byte)stats.Gray.Max;
            double aggregate = 0;

            int width = pixels.GetLength(0);
            int height = pixels.GetLength(1);

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    aggregate += pixels[i, j];
                }
            }

            aggregate = Math.Pow(width * height, -1) * aggregate;
            return (maxGrayLevel - minGrayLevel) / aggregate;
        }