// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Collections.Generic; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Processors; using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.Primitives; using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Convolution { using SixLabors.ImageSharp.Processing.Convolution; using SixLabors.ImageSharp.Processing.Convolution.Processors; 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 : IEdgeDetectorProcessor { 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 : IEdgeDetectorProcessor { 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); } } }