private void PlotGaussFilter() { var plotGauss = new PlotModel { Title = $"Gauss Filter Plot for {fileInfo.Name}" }; plotGauss.Axes.Add(new LinearAxis { Title = "Sigma", Position = AxisPosition.Bottom }); plotGauss.Axes.Add(new LinearAxis { Title = "PSNR", Position = AxisPosition.Left }); using (var imageLoader = new ImageLoader()) { imageLoader.Load(fileInfo.FullName); Image image = imageLoader.Image; Image noise = imageLoader.AddNoise(new GaussNoise(new Normal(0, 0.25))).Image; for (var R = 1; R <= 8; R++) { var points = new LineSeries { StrokeThickness = 2, MarkerSize = 4, Title = $"R = {R}" }; points.MarkerType = MarkerType.Circle; for (var sigma = 0.5; sigma <= 3; sigma += 0.5) { imageLoader.Image = noise; imageLoader.AddGaussFilter(R, sigma); double psnr = imageLoader.CalculatePSNR(image); points.Points.Add(new DataPoint(sigma, psnr)); imageLoader.Image = image; } plotGauss.Series.Add(points); } } pngExporter.ExportToFile(plotGauss, $"{outputPath}/{fileInfo.Name}/GaussFilterPlot.png"); }
void PlotGaussR() { var plotGauss = new PlotModel { Title = $"Gauss R with sigma 2 for {fileInfo.Name}" }; plotGauss.Axes.Add(new LinearAxis { Title = "R", Position = AxisPosition.Bottom }); plotGauss.Axes.Add(new LinearAxis { Title = "PSNR", Position = AxisPosition.Left }); using (var imageLoader = new ImageLoader()) { imageLoader.Load(fileInfo.FullName); Image image = imageLoader.Image; var points = new LineSeries { StrokeThickness = 2, MarkerSize = 4, Color = OxyColors.Red }; for (var R = 1; R <= 8; R++) { //imageLoader.Image = noise; imageLoader.AddNoise(new GaussNoise(new Normal(0, 35))); // 100 dispersy imageLoader.AddGaussFilter(R, 2); double psnr = imageLoader.CalculatePSNR(image); points.Points.Add(new DataPoint(R, psnr)); imageLoader.Image = image; } plotGauss.Series.Add(points); } pngExporter.ExportToFile(plotGauss, $"{outputPath}/{fileInfo.Name}/GaussFilterPlotR.png"); }
private static void GaussFilter(FileInfo file, string outputFileName) { Console.WriteLine("***GAUSS FILTER***"); if (file == null) { throw new ArgumentNullException(nameof(file)); } using (var imageLoader = new ImageLoader()) { imageLoader.Load(file.FullName); Image image = imageLoader.Image; imageLoader.AddNoise(new GaussNoise(new Normal(0, 0.25))); imageLoader.Save($"{outputFileName}gaussnoise{file.Extension}"); Console.WriteLine($"psnr-noise: {imageLoader.CalculatePSNR(image):F2}"); imageLoader.AddGaussFilter(4, 1.6); imageLoader.Save($"{outputFileName}gaussfiltered{file.Extension}"); Console.WriteLine($"psnr-gaussfilter: {imageLoader.CalculatePSNR(image):F2}"); } }