From 5ffdbc20c939fed2ca6078f217dd5bc4bc5990b9 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Tue, 15 Aug 2017 05:00:14 +0200 Subject: [PATCH] optimized DetectEdgesTest --- .../Processors/Convolution/DetectEdgesTest.cs | 19 +++++++++++-------- tests/ImageSharp.Tests/TestImages.cs | 1 + tests/Images/Input/Png/BikeGrayscale.png | 3 +++ 3 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 tests/Images/Input/Png/BikeGrayscale.png diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs index 18342ee81..43d3d0d02 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs @@ -13,7 +13,8 @@ namespace ImageSharp.Tests.Processing.Processors.Convolution public class DetectEdgesTest : FileTestBase { public static readonly string[] CommonTestImages = { TestImages.Png.Bike }; - + public static readonly string[] GrayscaleTestImages = { TestImages.Png.BikeGrayscale }; + public static readonly TheoryData DetectEdgesFilters = new TheoryData { EdgeDetection.Kayyali, @@ -29,30 +30,32 @@ namespace ImageSharp.Tests.Processing.Processors.Convolution }; [Theory] - [WithFileCollection(nameof(DefaultFiles), nameof(DetectEdgesFilters), DefaultPixelType)] + [WithTestPatternImages(nameof(DetectEdgesFilters), 100, 100, DefaultPixelType)] + [WithFileCollection(nameof(CommonTestImages), nameof(DetectEdgesFilters), DefaultPixelType)] public void DetectEdges(TestImageProvider provider, EdgeDetection detector) where TPixel : struct, IPixel { using (Image image = provider.GetImage()) { image.Mutate(x => x.DetectEdges(detector)); - image.DebugSave(provider, detector.ToString()); + image.DebugSave(provider, detector.ToString(), grayscale: true); } } [Theory] - [WithFileCollection(nameof(DefaultFiles), nameof(DetectEdgesFilters), DefaultPixelType)] - public void DetectEdgesInBox(TestImageProvider provider, EdgeDetection detector) + [WithFileCollection(nameof(GrayscaleTestImages), DefaultPixelType)] + public void DetectEdgesInBox(TestImageProvider provider) where TPixel : struct, IPixel { using (Image source = provider.GetImage()) - using (var image = source.Clone()) + using (Image image = source.Clone()) { var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); - image.Mutate(x => x.DetectEdges(detector, bounds)); - image.DebugSave(provider, detector.ToString()); + image.Mutate(x => x.DetectEdges(bounds)); + image.DebugSave(provider, grayscale: true); + // TODO: We don't need this any longer after switching to ReferenceImages ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); } } diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 33a1f4154..527b78ae6 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -29,6 +29,7 @@ namespace ImageSharp.Tests public const string CalliphoraPartial = "Png/CalliphoraPartial.png"; public const string CalliphoraPartialGrayscale = "Png/CalliphoraPartialGrayscale.png"; public const string Bike = "Png/Bike.png"; + public const string BikeGrayscale = "Png/BikeGrayscale.png"; public const string Rgb48BppInterlaced = "Png/rgb-48bpp-interlaced.png"; // Filtered test images from http://www.schaik.com/pngsuite/pngsuite_fil_png.html diff --git a/tests/Images/Input/Png/BikeGrayscale.png b/tests/Images/Input/Png/BikeGrayscale.png new file mode 100644 index 000000000..652a1af0a --- /dev/null +++ b/tests/Images/Input/Png/BikeGrayscale.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b4304d42e522e841f870f57fa3cdab38d2f26784ac6eaaa2cbcbc55649be0bd7 +size 98064