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

NiblackTest3() private méthode

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

            Bitmap input;
            new MatrixToImage()
                {
                    Format = PixelFormat.Format32bppRgb,
                }.Convert(diag, out input);

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

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

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

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

            double[,] actual;

            for (int i = 0; i < 3; i++)
            {

                new ImageToMatrix()
                {
                    Channel = i
                }.Convert(output, out actual);

                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));
            }
        }