public void AppliesThinningOnImage() { var structuringElement = new StructuringElement( new[, ] { { 0, 0, -1 }, { 1, 1, -1 }, { -1, -1, -1 } }); var inputImage = BinaryImage.FromByteArray( new byte[, ] { { 0, 0, 0 }, { 1, 1, 1 }, { 1, 1, 1 } }); var expected = BinaryImage.FromByteArray( new byte[, ] { { 0, 0, 0 }, { 1, 0, 0 }, { 1, 1, 1 } }); var structuringElements = new[] { structuringElement }; var result = Thinner.Thinning(inputImage, structuringElements); result.Should().Be( expected, $"result:\r\n{result.ToMatrixString()}\r\n should be as expected:\r\n{expected.ToMatrixString()}"); }
public void DisplaysContentAsMatrixString() { const string Expected = "x10\r\nx01\r\nx1x"; var sampleStructuringElement = new StructuringElement( new[, ] { { -1, 1, 0 }, { -1, 0, 1 }, { -1, 1, -1 } }); var result = sampleStructuringElement.ToString(); result.Should().Be(Expected); }
public void MatchesMatrixToStructuringElement() { var structuringElement = new StructuringElement( new[, ] { { 0, 0, 0 }, { -1, -1, -1 }, { 1, 1, 1 } }); var matchingMatrix = new BinaryMatrix( new byte[, ] { { 0, 0, 0 }, { 1, 0, 0 }, { 1, 1, 1 } }); bool result = Thinner.MatchMatrixToStructuringElement( matchingMatrix, structuringElement); result.Should().BeTrue(); }