// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageSharp.Tests.Processing.Convolution { using System.Collections.Generic; using ImageSharp.PixelFormats; using ImageSharp.Processing; using ImageSharp.Processing.Processors; using ImageSharp.Tests.TestUtilities; using SixLabors.Primitives; using Xunit; public class DetectEdgesTest : BaseImageOperationsExtensionTest { [Fact] public void DetectEdges_SobelProcessorDefaultsSet() { this.operations.DetectEdges(); var processor = this.Verify>(); Assert.True(processor.Grayscale); } [Fact] public void DetectEdges_Rect_SobelProcessorDefaultsSet() { this.operations.DetectEdges(this.rect); var processor = this.Verify>(this.rect); Assert.True(processor.Grayscale); } public static IEnumerable EdgeDetectionTheoryData => new[] { new object[]{ new TestType>(), EdgeDetection.Kayyali }, new object[]{ new TestType>(), EdgeDetection.Kirsch }, new object[]{ new TestType>(), EdgeDetection.Lapacian3X3 }, new object[]{ new TestType>(), EdgeDetection.Lapacian5X5 }, new object[]{ new TestType>(), EdgeDetection.LaplacianOfGaussian }, new object[]{ new TestType>(), EdgeDetection.Prewitt }, new object[]{ new TestType>(), EdgeDetection.RobertsCross }, new object[]{ new TestType>(), EdgeDetection.Robinson }, new object[]{ new TestType>(), EdgeDetection.Scharr }, new object[]{ new TestType>(), EdgeDetection.Sobel }, }; [Theory] [MemberData(nameof(EdgeDetectionTheoryData))] public void DetectEdges_filter_SobelProcessorDefaultsSet(TestType type, EdgeDetection filter) where TProcessor : IEdgeDetectorProcessor { this.operations.DetectEdges(filter); var processor = this.Verify(); Assert.True(processor.Grayscale); } [Theory] [MemberData(nameof(EdgeDetectionTheoryData))] public void DetectEdges_filter_grayscale_SobelProcessorDefaultsSet(TestType type, EdgeDetection filter) where TProcessor : IEdgeDetectorProcessor { var grey = (int)filter % 2 == 0; this.operations.DetectEdges(filter, grey); var processor = this.Verify(); Assert.Equal(grey, processor.Grayscale); } } }