public void SauvolaTest2() { double[,] diag = Matrix.Magic(5); Bitmap input; new MatrixToImage().Convert(diag, out input); // Create a new Variance filter SauvolaThreshold filter = new SauvolaThreshold(); 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[,] { { 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 } }; Assert.IsTrue(expected.IsEqual(actual, 1e-6)); }
public void SauvolaTest1() { Bitmap image = Accord.Imaging.Image.Clone(Properties.Resources.lena512); SauvolaThreshold sauvola = new SauvolaThreshold(); Bitmap result = sauvola.Apply(image); // ImageBox.Show(result); Assert.IsNotNull(result); }
public void SauvolaTest3() { double[,] diag = Matrix.Magic(5); Bitmap input; new MatrixToImage() { Format = PixelFormat.Format32bppRgb, }.Convert(diag, out input); Assert.AreEqual(PixelFormat.Format32bppRgb, input.PixelFormat); SauvolaThreshold filter = new SauvolaThreshold(); // 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[,] { { 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 } }; Assert.IsTrue(expected.IsEqual(actual, 1e-6)); } }