public void SumTest2() { Bitmap image = Accord.Imaging.Image.Clone(Resources.image2); int expected = 0; for (int i = 3; i < 9; i++) { for (int j = 2; j < 10; j++) { expected += image.GetPixel(i, j).R; } } int actual = (int)Tools.Sum(image, new Rectangle(3, 2, 9 - 3, 10 - 2)); Assert.AreEqual(expected, actual); }
public void SumTest() { Bitmap image = Accord.Imaging.Image.Clone(Resources.image1); int expected = 0; for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { expected += image.GetPixel(i, j).R; } } int actual = (int)Tools.Sum(image); Assert.AreEqual(expected, actual); }
public void SumTest1() { Bitmap image = Accord.Imaging.Image.Clone(Resources.image2); int expected = 0; for (int i = 3; i < 9; i++) { for (int j = 2; j < 10; j++) { expected += image.GetPixel(i, j).R; } } BitmapData data = image.LockBits(new Rectangle(System.Drawing.Point.Empty, image.Size), ImageLockMode.ReadOnly, image.PixelFormat); int actual = Tools.Sum(data, new Rectangle(3, 2, 9 - 3, 10 - 2)); Assert.AreEqual(expected, actual); image.UnlockBits(data); }