Exemplo n.º 1
0
        public static void DeleteColumnFieldTest(FieldParameters fp)
        {
            DeleteColumns deleteCol = new DeleteColumns(fp, (new int[] { 0, 1, 2, 3, 5, 7, 15, 16, 17, 18 }));

            deleteCol.Apply();
            fp.Generate().GenerateImage().Save("tests/FilterTests/nachColLöschen.png");
            SaveFieldPlan(fp, "tests/FilterTests/FeldplanNachColLöschen.html");
            deleteCol.Undo();
            fp.Generate().GenerateImage().Save("tests/FilterTests/nachColLoeschenUndo.png");
        }
Exemplo n.º 2
0
        public static void DeleteRowFieldTest(FieldParameters fp)
        {
            DeleteRows deleteRow = new DeleteRows(fp, (new int[] { 0, fp.current_height - 1 }).Select(x => x * fp.current_width).ToArray());

            deleteRow.Apply();
            fp.Generate().GenerateImage().Save("tests/FilterTests/nachRowLöschen.png");
            SaveFieldPlan(fp, "tests/FilterTests/FeldplanNachRowLöschen.html");
            deleteRow.Undo();
            fp.Generate().GenerateImage().Save("tests/FilterTests/nachRowLoeschenUndo.png");
        }
Exemplo n.º 3
0
        public void CheckTransparency()
        {
            InitializeWorkspace();
            FieldParameters p = new FieldParameters("image_transparency.png", "colors.DColor", 8, 8, 24, 8, 20000, Inter.Lanczos4,
                                                    new Dithering(), ColorDetectionMode.CieDe2000Comparison, new NoColorRestriction());

            p.TransparencySetting = 128;
            DominoTransfer t = p.Generate();

            Assert.AreEqual(0, t.dominoes[0]);
            p.background = Colors.White;
            t            = p.Generate();
            Assert.AreEqual(29, t.dominoes[0]);
        }
Exemplo n.º 4
0
        public static void InsertColumnFieldTest(FieldParameters fp)
        {
            AddColumns addCol = new AddColumns(fp, 1, 5, 5, true);

            addCol.Apply();
            AddColumns addCol2 = new AddColumns(fp, 0, 5, 5, false);

            addCol2.Apply();
            fp.Generate().GenerateImage().Save("tests/FilterTests/nachColumnEinfügen.png");
            SaveFieldPlan(fp, "tests/FilterTests/FeldplanNachColumnEinfuegen.html");
            addCol2.Undo();
            addCol.Undo();
            fp.Generate().GenerateImage().Save("tests/FilterTests/nachColumnEinfügenUndo.png");
        }
Exemplo n.º 5
0
        public static void InsertRowFieldTest(FieldParameters fp)
        {
            AddRows addRows = new AddRows(fp, fp.Height * fp.Length - 1, 5, 5, true);

            addRows.Apply();
            AddRows addRows2 = new AddRows(fp, 0, 5, 5, false);

            addRows2.Apply();
            fp.Generate().GenerateImage().Save("tests/FilterTests/nachRowEinfügen.png");
            SaveFieldPlan(fp, "tests/FilterTests/FeldplanNachRowEinfuegen.html");
            addRows2.Undo();
            addRows.Undo();
            fp.Generate().GenerateImage().Save("tests/FilterTests/nachRowEinfügenUndo.png");
        }
Exemplo n.º 6
0
        public static void PostFilterFieldTest(string path)
        {
            FieldParameters fp = new FieldParameters(Path.GetFullPath("tests/PostFilterTest.DObject"), path, "colors.DColor", 8, 8, 24, 8, 10000, Emgu.CV.CvEnum.Inter.Lanczos4,
                                                     ColorDetectionMode.Cie94Comparison, new Dithering(), new NoColorRestriction());

            fp.Generate().GenerateImage().Save("tests/FilterTests/vorFilter.png");
            InsertRowFieldTest(fp);
            DeleteRowFieldTest(fp);
            CopyPasteFieldTest(fp);
            InsertColumnFieldTest(fp);
            DeleteColumnFieldTest(fp);
        }
Exemplo n.º 7
0
        public static void CopyPasteFieldTest(FieldParameters fp)
        {
            int[] source_area = new int[400];
            int   startx      = 20;
            int   starty      = 20;
            int   target_x    = 30;
            int   target_y    = 30;

            for (int i = 0; i < 20; i++)
            {
                for (int j = 0; j < 20; j++)
                {
                    source_area[j * 20 + i] = fp.current_width * (j + starty) + (startx + i);
                }
            }
            PasteFilter paste = new PasteFilter(fp, fp.current_width * starty + startx, source_area, fp.current_width * target_y + target_x);

            paste.Apply();
            fp.Generate().GenerateImage().Save("tests/FilterTests/nachPaste.png");
            paste.Undo();
            fp.Generate().GenerateImage().Save("tests/FilterTests/nachPasteUndo.png");
        }
Exemplo n.º 8
0
        static void FieldTest(String path)
        {
            Console.WriteLine("=======   FIELD TEST   =======");
            //Progress<String> progress = new Progress<string>(pr => Console.WriteLine(pr));
            //Mat mat = CvInvoke.Imread(path, ImreadModes.Unchanged);

            FieldParameters p = new FieldParameters(Path.GetFullPath("tests/FieldTest.DObject"), path, "colors.DColor", 8, 8, 24, 8, 20000, Inter.Lanczos4,
                                                    ColorDetectionMode.Cie1976Comparison, new Dithering(), new NoColorRestriction());

            ((FieldCalculation)p.PrimaryCalculation).TransparencySetting = 128;
            var watch = System.Diagnostics.Stopwatch.StartNew();

            p.Generate().GenerateImage().Save("tests/fieldtests_before_filters.png");
            watch.Stop();
            Console.WriteLine("elapsed: " + watch.ElapsedMilliseconds);

            /*watch.Restart();
             * p.ditherMode = new FloydSteinbergDithering();
             * watch.Stop();
             * Console.WriteLine("elapsed: " + watch.ElapsedMilliseconds);
             * watch.Restart();
             * p.Generate().GenerateImage().Save("tests/fieldtest_floyd_steinberg.png");
             * p.ditherMode = new Dithering();
             * watch.Stop();
             * Console.WriteLine("elapsed: " + watch.ElapsedMilliseconds);
             * watch.Restart();
             * p.Generate().GenerateImage().Save("tests/fieldtest_after_dithering.png");
             * p.ditherMode = new StuckiDithering();
             * watch.Stop();
             * Console.WriteLine("elapsed: " + watch.ElapsedMilliseconds);
             * watch.Restart();
             * p.Generate().GenerateImage().Save("tests/fieldtest_stucki.png");
             * p.ditherMode = new JarvisJudiceNinkeDithering();
             * watch.Stop();
             * Console.WriteLine("elapsed: " + watch.ElapsedMilliseconds);
             * watch.Restart();
             * p.Generate().GenerateImage().Save("tests/fieldtest_jjn.png");
             * watch.Stop();
             * Console.WriteLine("elapsed: " + watch.ElapsedMilliseconds);*/
            //DominoTransfer t = await Dispatcher.CurrentDispatcher.Invoke(async () => await Task.Run(() => p.Generate()));
            // Filtertests für ein Logo oder ähnliches

            /*var erster = ((BlendFileFilter)p.ImageFilters[0]);
             * erster.RotateAngle = 30;
             * erster.ScaleX = 0.5;
             * erster.ScaleY = 0.3;
             * erster.CenterX = erster.GetSizeOfMat().Width * 0.6;
             * erster.CenterY = erster.GetSizeOfMat().Height * 0.6;
             * var zweiter = new BlendTextFilter();
             * zweiter.FontSize = 40;
             * zweiter.FontFamily = "Calibri";
             * zweiter.Text = "Hallo Welt";
             * zweiter.Color = System.Drawing.Color.Green;
             * p.ImageFilters.Add(zweiter);
             * zweiter.CenterX = 500;
             * zweiter.CenterY = 500;*/
            // Filtertests für Bilder
            // Helligkeit / Kontrast

            /*var hell = new ContrastLightFilter();
             * hell.Alpha = 1.5;
             * hell.Beta = -150;
             * p.ImageFilters.Add(hell);*/
            //var gamma = new GammaCorrectFilter();
            //gamma.Gamma = 1.1;
            //p.ImageFilters.Add(gamma);

            /*var blur = new GaussianSharpenFilter();
             * blur.KernelSize = 21;
             * blur.StandardDeviation = 5;
             * blur.SharpenWeight = 0.5;
             * p.ImageFilters.Add(blur);*/
            /*var replace = new ReplaceColorFilter();
             * replace.BeforeColor = System.Drawing.Color.LightBlue;
             * replace.AfterColor = System.Drawing.Color.Red;
             * replace.Tolerance = 50;
             * p.ImageFilters.Add(replace);*/
            //p.ColorFilters.Add(new ChangeCountColorFilter() { Index = 14, NewCount = 0 });
            //p.ColorFilters.Add(new ChangeRGBColorFilter() { Index = 30, Color = Colors.Green });
            //p.Generate();

            /*Console.WriteLine(String.Join("\n", p.counts));
             * Console.WriteLine("Size: " + p.Generate().shapes.Count());
             * watch.Stop();
             * Console.WriteLine(watch.ElapsedMilliseconds);
             * watch = System.Diagnostics.Stopwatch.StartNew();
             * Mat b2 = p.Generate().GenerateImage(Colors.Transparent, 2000);
             * watch.Stop();
             * Console.WriteLine(watch.ElapsedMilliseconds);
             * b2.Save("tests/FieldTest.png");
             * FileStream fs = new FileStream(@"tests/FieldPlanTest.html", FileMode.Create);
             * StreamWriter sw = new StreamWriter(fs);*/
            /*sw.Write(p.GetHTMLProcotol(new ObjectProtocolParameters()
             * {
             *  backColorMode = ColorMode.Normal,
             *  foreColorMode = ColorMode.Intelligent,
             *  orientation = Core.Orientation.Horizontal,
             *  reverse = false,
             *  summaryMode = SummaryMode.Large,
             *  textFormat = "<font face=\"Verdana\">",
             *  templateLength = 20,
             *  textRegex = "%count% %color%",
             *  title = "Field"
             * }));*/
            /*p.SaveXLSFieldPlan("tests/ExcelFieldPlanTest.xlsx", new ObjectProtocolParameters()
             * {
             *  backColorMode = ColorMode.Normal,
             *  foreColorMode = ColorMode.Intelligent,
             *  orientation = Core.Orientation.Horizontal,
             *  reverse = false,
             *  summaryMode = SummaryMode.Large,
             *  textFormat = "<font face=\"Verdana\">",
             *  templateLength = 20,
             *  textRegex = "%count%",
             *  title = "Field",
             *  path = Directory.GetCurrentDirectory()
             *
             * });*/
            //sw.Close();
            p.Save();
            watch = Stopwatch.StartNew();
            int[] counts = Workspace.LoadColorList <FieldParameters>(Path.GetFullPath("tests/FieldTest.DObject")).Item2;
            watch.Stop();
            Console.WriteLine("Preview Load Time: " + watch.ElapsedMilliseconds);
            Console.WriteLine(String.Join(", ", counts));

            Workspace.Clear();
            watch = Stopwatch.StartNew();
            FieldParameters loaded = Workspace.Load <FieldParameters>(Path.GetFullPath("tests/FieldTest.DObject"));

            loaded.Generate();
            watch.Stop();
            Console.WriteLine("Load Time: " + watch.ElapsedMilliseconds);
            //loaded.last.GenerateImage(Colors.Transparent).Save("tests/afterLoad.png");
            Console.WriteLine(p.colors == loaded.colors);
            watch = Stopwatch.StartNew();
            int[] counts2 = Workspace.LoadColorList <FieldParameters>(Path.GetFullPath("tests/FieldTest.DObject")).Item2;
            watch.Stop();
            Console.WriteLine("Preview Load Time: " + watch.ElapsedMilliseconds);
            Console.WriteLine(String.Join(", ", counts2));
            Console.WriteLine("Number of image filters: " + ((FieldReadout)loaded.PrimaryImageTreatment).ImageFilters.Count);
            //loaded.ImageHeight = 1500;
            //loaded.ColorFilters.Add(new ChangeCountColorFilter() { Index = 14, NewCount = 0 });
            //loaded.ColorFilters.Add(new ChangeRGBColorFilter() { Index = 30, Color = Colors.Green });
            //t = loaded.Generate();
            p.Generate().GenerateImage().Save("tests/fieldtest_after_load.png");

            Console.WriteLine(String.Join(", ", loaded.Counts));
        }