public void ConnectedComponentsThinLinksAndGapsImage()
        {
            var cc    = new ConnectedComponentsTask();
            var gen   = new ConnectedComponentsTestImages();
            Mat image = gen.ThinLinksAndGapsImage();

            int originalAnswer = cc.CountConnectedComponents(image);

            Assert.AreEqual(4, originalAnswer);

            Mat dilated3       = cc.Dilate(image, 3);
            int dilated3Answer = cc.CountConnectedComponents(dilated3);

            Assert.AreEqual(3, dilated3Answer);

            Mat dilated8       = cc.Dilate(image, 8);
            int dilated8Answer = cc.CountConnectedComponents(dilated8);

            Assert.AreEqual(2, dilated8Answer);

            Mat eroded1       = cc.Erode(image, 1);
            int eroded1Answer = cc.CountConnectedComponents(eroded1);

            Assert.AreEqual(5, eroded1Answer);
        }
        public void ConnectedComponentsCirclesInGridSkipDiagonalImage()
        {
            var cc  = new ConnectedComponentsTask();
            var gen = new ConnectedComponentsTestImages();
            int correctAnswer;
            Mat image  = gen.CirclesInGridSkipDiagonalImage(out correctAnswer);
            int answer = cc.CountConnectedComponents(image);

            Assert.AreEqual(correctAnswer, answer);
        }
        public void ConnectedComponentsImageWithText()
        {
            var cc  = new ConnectedComponentsTask();
            var gen = new ConnectedComponentsTestImages();
            int correctAnswer;
            Mat image  = gen.ImageWithText(out correctAnswer);
            int answer = cc.CountConnectedComponents(image);

            Assert.AreEqual(correctAnswer, answer);
        }
        public void ConnectedComponentsThinLineShapeImage()
        {
            var cc  = new ConnectedComponentsTask();
            var gen = new ConnectedComponentsTestImages();
            int correctAnswer;
            Mat image  = gen.ThinLineShapeImage(out correctAnswer);
            int answer = cc.CountConnectedComponents(image);

            Assert.AreEqual(correctAnswer, answer);
        }
Пример #5
0
        static void Main(string[] args)
        {
            IntroHelper helper = new IntroHelper();
            Mat         image  = helper.CreateEmptyGreenImage();
            var         color  = helper.GetPixelColor(image, new Point(10, 10));

            Console.WriteLine("Mizu?");

            // Save all test images into PNG files.
            ConnectedComponentsTestImages genCC = new ConnectedComponentsTestImages();
            int dummy;

            Cv2.ImWrite("TrivialImage.png", genCC.TrivialImage(out dummy));
            Cv2.ImWrite("SingleRectImage.png", genCC.SingleRectImage(out dummy));
            Cv2.ImWrite("ComplexShapeImage.png", genCC.ComplexShapeImage(out dummy));
            Cv2.ImWrite("ThinLineShapeImage.png", genCC.ThinLineShapeImage(out dummy));
            Cv2.ImWrite("CirclesInGridSkipDiagonalImage.png", genCC.CirclesInGridSkipDiagonalImage(out dummy));
            Cv2.ImWrite("ImageWithText.png", genCC.ImageWithText(out dummy));
            Cv2.ImWrite("ThinLinksAndGapsImage.png", genCC.ThinLinksAndGapsImage());

            BoundingBoxTestImages genBBox = new BoundingBoxTestImages();
            int d1, d2, d3, d4; // Dummy variables

            Cv2.ImWrite("SimpleRectangleImage.png", genBBox.SimpleRectangleImage(out d1, out d2, out d3, out d4));
            Cv2.ImWrite("RandomPolygonImage.png", genBBox.RandomPolygonImage(out d1, out d2, out d3, out d4));

            BlobSizeHistogramTestImages genBlobSizeHist = new BlobSizeHistogramTestImages();

            Cv2.ImWrite("RandomBlobs.png", genBlobSizeHist.RandomBlobs(100, 200, out dummy));



            // Show window until keypress or max. 5 seconds
            Mat img = genCC.CirclesInGridSkipDiagonalImage(out dummy);

            Cv2.ImShow("CirclesInGridSkipDiagonalImage", img);
            Cv2.WaitKey(5000);
        }