コード例 #1
0
        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()}");
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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();
        }