コード例 #1
0
        static void Experiment5Taskv2Performence()
        {
            int    level = 2;
            string name  = "lenna";

            Logger.Info(name);
            string inputName = $"../../../test_images/{name}.png";
            Bitmap input     = new Bitmap(inputName);
            Bitmap output    = new Bitmap(input.Width, input.Height, input.PixelFormat);

            var imageReader = new BitmapReader <int>(input);
            var mallat      = new MallatDecomposition <int, NineSevenBiortogonalInteger <int> >(imageReader).Build(input.Size, level);

            Logger.Info(mallat.ToString());
            var    calculator      = new MallatEntropyEvaluator <int>(input.Size, level, mallat);
            var    mallatCollector = new MallatMerger <int>(input.Size, level, mallat);
            var    imageWriter     = new BitmapWriter <int>(new Bitmap(input.Width, input.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb), "", mallatCollector);
            string outputName      = $"{inputName}_{mallat.ToString()}.png";

            imageWriter.SetImageName(outputName);
            calculator.DataLength = 3;

            var sw = System.Diagnostics.Stopwatch.StartNew();

            Logger.Info("Sync:");
            imageWriter.Process();
            Logger.Info($"Time:\t{sw.Elapsed}");
            sw.Restart();
            Logger.Info("Async v2:");
            imageWriter.ProcessAsync();
            Logger.Info($"Time:\t{sw.Elapsed}");
        }
コード例 #2
0
        static void ExperimentEntropy(string name, int level)
        {
            string folder    = "../../../test_images";
            string inputName = $"{folder}/{name}.png";

            Logger.Info(inputName);
            Bitmap input  = new Bitmap(inputName);
            Bitmap output = new Bitmap(input.Width, input.Height, input.PixelFormat);

            var tester = new MallatTester <int>((GetMallat) =>
            {
                var imageReader = new BitmapReader <int>(input);
                var mallat      = GetMallat(imageReader);
                Logger.Info(mallat.ToString());
                var calculator      = new MallatEntropyEvaluator <int>(input.Size, level, (Segment <int>)mallat);
                var mallatCollector = new MallatMerger <int>(input.Size, level, (Segment <int>)mallat);
                var imageWriter     = new BitmapWriter <int>(new Bitmap(input.Width, input.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb), "", mallatCollector);
                string outputName   = $"{folder}/{level}/{name}_{mallat.ToString()}.png";
                imageWriter.SetImageName(outputName);
                calculator.DataLength = 3;
                return(new Node <int>[] { imageWriter, calculator });
            });

            tester.AddNewMallat((predecessor) => { return(new MallatDecomposition <int, TwoTwoInterpolatingInteger <int> >(predecessor).Build(input.Size, level)); });
            tester.AddNewMallat((predecessor) => { return(new MallatDecomposition <int, FourTwoInterpolatingInteger <int> >(predecessor).Build(input.Size, level)); });
            tester.AddNewMallat((predecessor) => { return(new MallatDecomposition <int, TwoFourInterpolatingInteger <int> >(predecessor).Build(input.Size, level)); });
            tester.AddNewMallat((predecessor) => { return(new MallatDecomposition <int, FourFourInterpolatingInteger <int> >(predecessor).Build(input.Size, level)); });
            tester.AddNewMallat((predecessor) => { return(new MallatDecomposition <int, TwoPlusTwoTwoInteger <int> >(predecessor).Build(input.Size, level)); });
            tester.AddNewMallat((predecessor) => { return(new MallatDecomposition <int, DaubechiesWaveletD4Integer <int> >(predecessor).Build(input.Size, level)); });
            tester.AddNewMallat((predecessor) => { return(new MallatDecomposition <int, NineSevenBiortogonalInteger <int> >(predecessor).Build(input.Size, level)); });
            tester.AddNewMallat((predecessor) => { return(new MallatDecomposition <int, BaseWavelet <int> >(predecessor).Build(input.Size, level)); });

            var sw = System.Diagnostics.Stopwatch.StartNew();

            tester.RunAsync();
            Logger.Info($"Time:\t{sw.Elapsed}");
        }