Accord.Tests.Imaging.NiblackTest.NiblackTest2 C# (CSharp) Méthode

NiblackTest2() private méthode

private NiblackTest2 ( ) : void
Résultat void
        public void NiblackTest2()
        {
            double[,] diag = Matrix.Magic(5);

            Bitmap input;
            new MatrixToImage().Convert(diag, out input);

            // Create a new Variance filter
            NiblackThreshold filter = new NiblackThreshold();

            Assert.AreEqual(PixelFormat.Format8bppIndexed, input.PixelFormat);

            // Apply the filter
            Bitmap output = filter.Apply(input);

            double[,] actual;

            new ImageToMatrix().Convert(output, out actual);

            Assert.AreEqual(PixelFormat.Format8bppIndexed, output.PixelFormat);

            string str = actual.ToString(CSharpMatrixFormatProvider.InvariantCulture);

            double[,] expected = new double[,] 
            {
                { 0, 0, 1, 1, 0 },
                { 0, 1, 1, 0, 0 },
                { 1, 1, 0, 0, 0 },
                { 1, 0, 0, 0, 1 },
                { 1, 0, 0, 1, 1 } 
            };

            Assert.IsTrue(expected.IsEqual(actual, 1e-6));
        }