示例#1
0
        public void Noise_Is_Applied()
        {
            foreach (FileInfo file in TestImages.GetTestImagesFromTestFolder(""))
            {
                string outputFileName = $"{OutputPath}{file.Name.Substring(0, file.Name.LastIndexOf('.'))}";

                using (var imageLoader = new ImageLoader())
                {
                    var noises = new List <INoise>
                    {
                        new GaussNoise(new Normal(0, 0.25)),
                        new ImpulseNoise(0.025, 0.025)
                    };
                    imageLoader.Load(file.FullName);
                    Image image = imageLoader.Image;

                    foreach (INoise noise in noises)
                    {
                        string noiseFileName = $"{outputFileName}_{noise.GetType().Name.ToLower()}{file.Extension}";
                        imageLoader.AddNoise(noise);
                        imageLoader.Save(noiseFileName);
                        Assert.IsTrue(File.Exists(noiseFileName));
                        ImageAssert.AssertImagesAreDifferent(image, imageLoader.Image);
                        imageLoader.Image = image;
                    }

                    //File.Delete(outputFileName);
                }
            }
        }