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(); // Apply the filter Bitmap output = filter.Apply(input); double[,] actual; new ImageToMatrix().Convert(output, out actual); string str = actual.ToString(CSharpMatrixFormatProvider.InvariantCulture); double[,] expected = { { 0, 0, 0, 0, 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)); }
private void SetFilter() { ImageType = ImageTypes.Rgb24bpp; Af.NiblackThreshold newFilter = new Af.NiblackThreshold(); newFilter.K = k; newFilter.C = Remap(c, 0, 255); newFilter.Radius = radius; imageFilter = newFilter; }
public void NiblackTest1() { Bitmap image = Properties.Resources.lena512; NiblackThreshold niblack = new NiblackThreshold(); Bitmap result = niblack.Apply(image); // ImageBox.Show(result); Assert.IsNotNull(result); }
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)); } }