Browse Source

drop IEdgeDetectorProcessor

af/merge-core
Anton Firszov 7 years ago
parent
commit
91d0f6fd02
  1. 9
      src/ImageSharp/Processing/DetectEdgesExtensions.cs
  2. 5
      src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs
  3. 8
      src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessorHelpers.cs
  4. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor.cs
  5. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor.cs
  6. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor.cs
  7. 1
      src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs
  8. 28
      src/ImageSharp/Processing/Processors/Convolution/IEdgeDetectorProcessor.cs
  9. 4
      src/ImageSharp/Processing/Processors/IImageProcessor{TPixel}.cs
  10. 4
      src/ImageSharp/Processing/Processors/ImageProcessorExtensions.cs
  11. 2
      src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor.cs
  12. 4
      tests/ImageSharp.Tests/Processing/Convolution/DetectEdgesTest.cs

9
src/ImageSharp/Processing/DetectEdgesExtensions.cs

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Processing.Processors.Convolution;
using SixLabors.Primitives;
@ -82,7 +83,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="source">The image this method extends.</param>
/// <param name="filter">The filter for detecting edges.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DetectEdges<TPixel>(this IImageProcessingContext<TPixel> source, IEdgeDetectorProcessor<TPixel> filter)
private static IImageProcessingContext<TPixel> DetectEdges<TPixel>(this IImageProcessingContext<TPixel> source, IImageProcessor<TPixel> filter)
where TPixel : struct, IPixel<TPixel>
{
return source.ApplyProcessor(filter);
@ -98,17 +99,17 @@ namespace SixLabors.ImageSharp.Processing
/// </param>
/// <param name="filter">The filter for detecting edges.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DetectEdges<TPixel>(this IImageProcessingContext<TPixel> source, Rectangle rectangle, IEdgeDetectorProcessor<TPixel> filter)
private static IImageProcessingContext<TPixel> DetectEdges<TPixel>(this IImageProcessingContext<TPixel> source, Rectangle rectangle, IImageProcessor<TPixel> filter)
where TPixel : struct, IPixel<TPixel>
{
source.ApplyProcessor(filter, rectangle);
return source;
}
private static IEdgeDetectorProcessor<TPixel> GetProcessor<TPixel>(EdgeDetectionOperators filter, bool grayscale)
private static IImageProcessor<TPixel> GetProcessor<TPixel>(EdgeDetectionOperators filter, bool grayscale)
where TPixel : struct, IPixel<TPixel>
{
IEdgeDetectorProcessor<TPixel> processor;
IImageProcessor<TPixel> processor;
switch (filter)
{

5
src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs

@ -1,5 +1,5 @@
// // Copyright (c) Six Labors and contributors.
// // Licensed under the Apache License, Version 2.0.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Primitives;
@ -38,7 +38,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// </summary>
public DenseMatrix<float> KernelY { get; }
/// <inheritdoc/>
protected override void OnFrameApply(
ImageFrame<TPixel> source,

8
src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessorHelpers.cs

@ -1,5 +1,5 @@
// // Copyright (c) Six Labors and contributors.
// // Licensed under the Apache License, Version 2.0.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
{
/// <summary>
/// Kernel radius is calculated using the minimum viable value.
/// <see cref="http://chemaguerra.com/gaussian-filter-radius/"/>.
/// See http://chemaguerra.com/gaussian-filter-radius/ .
/// </summary>
internal static int GetDefaultGaussianRadius(float sigma)
{
@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
}
/// <summary>
/// Create a 1 dimensional Gaussian kernel using the Gaussian G(x) function
/// Create a 1 dimensional Gaussian kernel using the Gaussian G(x) function.
/// </summary>
/// <returns>The <see cref="DenseMatrix{T}"/>.</returns>
internal static DenseMatrix<float> CreateGaussianBlurKernel(int size, float weight)

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor.cs

@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// Defines a processor that detects edges within an image using two one-dimensional matrices.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
internal abstract class EdgeDetector2DProcessor<TPixel> : ImageProcessor<TPixel>, IEdgeDetectorProcessor<TPixel>
internal abstract class EdgeDetector2DProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor.cs

@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// Defines a processor that detects edges within an image using a eight two dimensional matrices.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
internal abstract class EdgeDetectorCompassProcessor<TPixel> : ImageProcessor<TPixel>, IEdgeDetectorProcessor<TPixel>
internal abstract class EdgeDetectorCompassProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor.cs

@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// Defines a processor that detects edges within an image using a single two dimensional matrix.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
internal abstract class EdgeDetectorProcessor<TPixel> : ImageProcessor<TPixel>, IEdgeDetectorProcessor<TPixel>
internal abstract class EdgeDetectorProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>

1
src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs

@ -70,6 +70,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// </summary>
public int Radius { get; }
/// <inheritdoc />
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>()
where TPixel : struct, IPixel<TPixel>
{

28
src/ImageSharp/Processing/Processors/Convolution/IEdgeDetectorProcessor.cs

@ -1,28 +0,0 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
namespace SixLabors.ImageSharp.Processing.Processors.Convolution
{
/// <summary>
/// Provides properties and methods allowing the detection of edges within an image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
public interface IEdgeDetectorProcessor<TPixel> : IImageProcessor<TPixel>, IEdgeDetectorProcessor
where TPixel : struct, IPixel<TPixel>
{
}
/// <summary>
/// Provides properties and methods allowing the detection of edges within an image.
/// </summary>
public interface IEdgeDetectorProcessor
{
/// <summary>
/// Gets a value indicating whether to convert the image to grayscale before performing edge detection.
/// </summary>
bool Grayscale { get; }
}
}

4
src/ImageSharp/Processing/Processors/IImageProcessor{TPixel}.cs

@ -1,5 +1,5 @@
// // Copyright (c) Six Labors and contributors.
// // Licensed under the Apache License, Version 2.0.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;

4
src/ImageSharp/Processing/Processors/ImageProcessorExtensions.cs

@ -1,5 +1,5 @@
// // Copyright (c) Six Labors and contributors.
// // Licensed under the Apache License, Version 2.0.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;

2
src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor.cs

@ -9,7 +9,7 @@ using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors.Transforms
{
/// <summary>
/// Implements resizing of images using various resamplers.
/// Defines an image resizing operation with the given <see cref="IResampler"/> and dimensional parameters.
/// </summary>
public class ResizeProcessor : IImageProcessor
{

4
tests/ImageSharp.Tests/Processing/Convolution/DetectEdgesTest.cs

@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Convolution
[Theory]
[MemberData(nameof(EdgeDetectionTheoryData))]
public void DetectEdges_filter_SobelProcessorDefaultsSet<TProcessor>(TestType<TProcessor> type, EdgeDetectionOperators filter)
where TProcessor : IEdgeDetectorProcessor<Rgba32>
where TProcessor : IImageProcessor<Rgba32>
{
this.operations.DetectEdges(filter);
@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Convolution
[Theory]
[MemberData(nameof(EdgeDetectionTheoryData))]
public void DetectEdges_filter_grayscale_SobelProcessorDefaultsSet<TProcessor>(TestType<TProcessor> type, EdgeDetectionOperators filter)
where TProcessor : IEdgeDetectorProcessor<Rgba32>
where TProcessor : IImageProcessor<Rgba32>
{
bool grey = (int)filter % 2 == 0;
this.operations.DetectEdges(filter, grey);

Loading…
Cancel
Save