// Copyright (c) Six Labors and contributors. // Licensed under the GNU Affero General Public License, Version 3. using System.Collections.Generic; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Processors.Convolution; using SixLabors.ImageSharp.Tests.TestUtilities; using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Convolution { public class DetectEdgesTest : BaseImageOperationsExtensionTest { [Fact] public void DetectEdges_SobelProcessorDefaultsSet() { this.operations.DetectEdges(); // TODO: Enable once we have updated the images SobelProcessor processor = this.Verify(); Assert.True(processor.Grayscale); } [Fact] public void DetectEdges_Rect_SobelProcessorDefaultsSet() { this.operations.DetectEdges(this.rect); // TODO: Enable once we have updated the images SobelProcessor processor = this.Verify(this.rect); Assert.True(processor.Grayscale); } public static IEnumerable EdgeDetectionTheoryData => new[] { new object[] { new TestType(), EdgeDetectionOperators.Kayyali }, new object[] { new TestType(), EdgeDetectionOperators.Kirsch }, new object[] { new TestType(), EdgeDetectionOperators.Laplacian3x3 }, new object[] { new TestType(), EdgeDetectionOperators.Laplacian5x5 }, new object[] { new TestType(), EdgeDetectionOperators.LaplacianOfGaussian }, new object[] { new TestType(), EdgeDetectionOperators.Prewitt }, new object[] { new TestType(), EdgeDetectionOperators.RobertsCross }, new object[] { new TestType(), EdgeDetectionOperators.Robinson }, new object[] { new TestType(), EdgeDetectionOperators.Scharr }, new object[] { new TestType(), EdgeDetectionOperators.Sobel }, }; [Theory] [MemberData(nameof(EdgeDetectionTheoryData))] public void DetectEdges_filter_SobelProcessorDefaultsSet(TestType type, EdgeDetectionOperators filter) where TProcessor : EdgeDetectorProcessor { this.operations.DetectEdges(filter); // TODO: Enable once we have updated the images var processor = this.Verify(); Assert.True(processor.Grayscale); } [Theory] [MemberData(nameof(EdgeDetectionTheoryData))] public void DetectEdges_filter_grayscale_SobelProcessorDefaultsSet(TestType type, EdgeDetectionOperators filter) where TProcessor : EdgeDetectorProcessor { bool grey = (int)filter % 2 == 0; this.operations.DetectEdges(filter, grey); // TODO: Enable once we have updated the images var processor = this.Verify(); Assert.Equal(grey, processor.Grayscale); } } }