Пример #1
0
        private static void LaplacianFilter(FileInfo file, string outputFileName)
        {
            Console.WriteLine("***LAPLACIAN FILTER***");

            if (file == null)
            {
                throw new ArgumentNullException(nameof(file));
            }
            double[] alphas = { 0, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6 };
            using (var imageLoader = new ImageLoader())
            {
                imageLoader.Load(file.FullName);
                imageLoader.AddNoise(new GaussNoise(new Normal(0.0001, 0.0001)));

                Image I = imageLoader.Image;
                Console.WriteLine($"Avg luma of src: {imageLoader.CalculateAvgLuminocity()}");

                imageLoader.PlotHistogram("src", OutputPath, file);

                foreach (var alpha in alphas)
                {
                    if (alpha == 0)
                    {
                        double[,] I1 = imageLoader.AddLaplacianFilterAlpha0();
                        //imageLoader.Save($"{outputFileName}_I1_laplacianfiltered{file.Extension}");

                        //Console.WriteLine($"Avg luma of I1: {imageLoader.CalculateAvgLuminocity()}");
                        //imageLoader.PlotHistogram("I1", OutputPath, file);

                        imageLoader.Add128(I1);
                        imageLoader.Save($"{outputFileName}_I1+128_laplacianfiltered{file.Extension}");

                        Console.WriteLine($"Avg luma of I1 + 128: {imageLoader.CalculateAvgLuminocity()}");
                        imageLoader.PlotHistogram("I1+128", OutputPath, file);
                        imageLoader.Image = I;


                        imageLoader.AddImage(I, I1);
                        imageLoader.Save($"{outputFileName}_I2_laplacianfiltered{file.Extension}");

                        Console.WriteLine($"Avg luma of I2: {imageLoader.CalculateAvgLuminocity()}");
                        imageLoader.PlotHistogram("I2", OutputPath, file);
                    }
                    else
                    {
                        imageLoader.AddLaplacianFilter(alpha);
                        imageLoader.Save($"{outputFileName}laplacianfiltered_(alpha={alpha}){file.Extension}");

                        Console.WriteLine($"Avg luma of alpha = {alpha}: {imageLoader.CalculateAvgLuminocity()}");
                        imageLoader.PlotHistogram($"alpha={alpha}", OutputPath, file);
                    }

                    imageLoader.Image = I;
                }
            }
        }