Exemple #1
0
        public void GenerateImagesForDoc()
        {
            //var testData0500 = TestDataFactory.Data.Single(x => x.ImageKey == "0500");
            //var testData0413 = TestDataFactory.Data.Single(x => x.ImageKey == "0413");

            var image     = new Mat(@"C:\Users\Winkler\Desktop\orig.png", LoadImageType.AnyColor);
            var keypoints = new List <Point> {
                new Point(140, 116), new Point(477, 120), new Point(163, 370), new Point(447, 369)
            };
            var testData0500 = new { Keypoints = keypoints, Image = image };

            var configMock = TestHelper.GetFakeConfig();
            //var quantizer = new Quantizer(configMock.Object);

            // simple threshold
            IQuantizer quantizer = new SimpleThresholdQuantizer {
                Threshold = 220
            };

            quantizer.Keypoints = testData0500.Keypoints;
            var quantizedImage = quantizer.Quantize(testData0500.Image);

            //TestHelper.Show(quantizedImage);
            TestHelper.Save(quantizedImage, "threshold_simple.png");

            // adaptive threshold
            quantizer = new Quantizer(configMock.Object)
            {
                ThresholdBlockSize = 17, ThresholdConstant = 6
            };
            quantizer.Keypoints = testData0500.Keypoints;
            quantizedImage      = quantizer.Quantize(testData0500.Image);
            //TestHelper.Show(quantizedImage);
            TestHelper.Save(quantizedImage, "threshold_adaptive.png");

            // warp
            quantizer           = new WarpOnlyQuantizer();
            quantizer.Keypoints = testData0500.Keypoints;
            quantizedImage      = quantizer.Quantize(testData0500.Image);
            //TestHelper.Show(quantizedImage);
            TestHelper.Save(quantizedImage, "warp_result.png");

            // morphological
            quantizer = new MorphologyQuantizer(configMock.Object)
            {
                ThresholdBlockSize = 17, ThresholdConstant = 6
            };
            quantizer.Keypoints = testData0500.Keypoints;
            quantizedImage      = quantizer.Quantize(testData0500.Image);
            //TestHelper.Show(quantizedImage);
            TestHelper.Save(quantizedImage, "opening_result.png");
        }
Exemple #2
0
        public void TastMany()
        {
            var testData = TestDataFactory.Data.First(x => x.ImageKey == "0500");

            var configMock = TestHelper.GetFakeConfig();
            var quantizer  = new MorphologyQuantizer(configMock.Object);

            quantizer.Keypoints = testData.Keypoints;

            for (int i = 0; i < 100; i++)
            {
                quantizer.Quantize(testData.Image);
            }
        }