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); } } }
public void Image_Is_Loaded_From_File() { foreach (var file in TestImages.GetTestImagesFromTestFolder("")) { using (var imageLoader = new ImageLoader()) { imageLoader.Load(file.FullName); Assert.AreEqual(imageLoader.ImagePath, file.FullName); Assert.NotNull(imageLoader.Image); } } }
public void Image_Is_Saved_To_File() { foreach (var file in TestImages.GetTestImagesFromTestFolder("")) { var outputFileName = $"{OutputPath}{file.Name}"; using (var imageLoader = new ImageLoader()) { imageLoader.Load(file.FullName); imageLoader.Save(outputFileName); Assert.IsTrue(File.Exists(outputFileName)); File.Delete(outputFileName); } } }
public void GaussFilter_Is_Applied() { foreach (FileInfo file in TestImages.GetTestImagesFromTestFolder("")) { string outputFileName = $"{OutputPath}{file.Name.Substring(0, file.Name.LastIndexOf('.'))}"; using (var imageLoader = new ImageLoader()) { imageLoader.Load(file.FullName); Image image = imageLoader.Image; string fileName = $"{outputFileName}_gaussFilter{file.Extension}"; imageLoader.AddGaussFilter(5, 1.4); imageLoader.Save(fileName); Assert.IsTrue(File.Exists(fileName)); ImageAssert.AssertImagesAreDifferent(image, imageLoader.Image); } } }