// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageSharp.Tests.Processing.Convolution { using ImageSharp.PixelFormats; using ImageSharp.Processing; using SixLabors.Primitives; using Xunit; public class DetectEdgesTest : FileTestBase { public static readonly TheoryData DetectEdgesFilters = new TheoryData { EdgeDetection.Kayyali, EdgeDetection.Kirsch, EdgeDetection.Lapacian3X3, EdgeDetection.Lapacian5X5, EdgeDetection.LaplacianOfGaussian, EdgeDetection.Prewitt, EdgeDetection.RobertsCross, EdgeDetection.Robinson, EdgeDetection.Scharr, EdgeDetection.Sobel }; [Theory] [WithFileCollection(nameof(DefaultFiles), nameof(DetectEdgesFilters), DefaultPixelType)] public void ImageShouldApplyDetectEdgesFilter(TestImageProvider provider, EdgeDetection detector) where TPixel : struct, IPixel { using (Image image = provider.GetImage()) { image.DetectEdges(detector) .DebugSave(provider, detector.ToString(), Extensions.Bmp); } } [Theory] [WithFileCollection(nameof(DefaultFiles), nameof(DetectEdgesFilters), DefaultPixelType)] public void ImageShouldApplyDetectEdgesFilterInBox(TestImageProvider provider, EdgeDetection detector) where TPixel : struct, IPixel { using (Image source = provider.GetImage()) using (var image = new Image(source)) { var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); image.DetectEdges(detector, bounds) .DebugSave(provider, detector.ToString(), Extensions.Bmp); ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); } } } }