Browse Source

optimized DetectEdgesTest

af/merge-core
Anton Firszov 9 years ago
parent
commit
5ffdbc20c9
  1. 19
      tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs
  2. 1
      tests/ImageSharp.Tests/TestImages.cs
  3. 3
      tests/Images/Input/Png/BikeGrayscale.png

19
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<EdgeDetection> DetectEdgesFilters = new TheoryData<EdgeDetection>
{
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<TPixel>(TestImageProvider<TPixel> provider, EdgeDetection detector)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> 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<TPixel>(TestImageProvider<TPixel> provider, EdgeDetection detector)
[WithFileCollection(nameof(GrayscaleTestImages), DefaultPixelType)]
public void DetectEdgesInBox<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (var image = source.Clone())
using (Image<TPixel> 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);
}
}

1
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

3
tests/Images/Input/Png/BikeGrayscale.png

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b4304d42e522e841f870f57fa3cdab38d2f26784ac6eaaa2cbcbc55649be0bd7
size 98064
Loading…
Cancel
Save