Accord.Imaging.Tools.Mean C# (CSharp) Method

Mean() public static method

Computes the arithmetic mean of the pixels in a given image.
public static Mean ( this image ) : double
image this
return double
        public static double Mean(this Bitmap image)
        {
            return (double)Sum(image) / (image.Width * image.Height);
        }

Same methods

Tools::Mean ( this image, Rectangle rectangle ) : double

Usage Example

コード例 #1
0
        public void MeanTest3()
        {
            UnmanagedImage image = UnmanagedImage.FromManagedImage(new byte[, ]
            {
                { 1, 2, 3 },
                { 4, 5, 6 },
                { 7, 8, 9 },
            }.ToBitmap());

            {
                Rectangle rectangle = new Rectangle(0, 0, 1, 2);
                double    expected  = (1 + 4) / 2.0;
                double    actual    = Tools.Mean(image, rectangle);
                Assert.AreEqual(expected, actual);
            }

            {
                double expected = (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9) / 9.0;
                double actual   = Tools.Mean(image);
                Assert.AreEqual(expected, actual);
            }
        }
All Usage Examples Of Accord.Imaging.Tools::Mean