📷 A modern, cross-platform, 2D Graphics library for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

50 lines
1.7 KiB

// <copyright file="PrewittProcessor.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Processing.Processors
{
using System;
using System.Diagnostics.CodeAnalysis;
/// <summary>
/// The Prewitt operator filter.
/// <see href="http://en.wikipedia.org/wiki/Prewitt_operator"/>
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
[SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")]
public class PrewittProcessor<TColor> : EdgeDetector2DProcessor<TColor>
where TColor : struct, IPackedPixel, IEquatable<TColor>
{
/// <summary>
/// The horizontal gradient operator.
/// </summary>
private static readonly Fast2DArray<float> PrewittX =
new Fast2DArray<float>(new float[,]
{
{ -1, 0, 1 },
{ -1, 0, 1 },
{ -1, 0, 1 }
});
/// <summary>
/// The vertical gradient operator.
/// </summary>
private static readonly Fast2DArray<float> PrewittY =
new Fast2DArray<float>(new float[,]
{
{ 1, 1, 1 },
{ 0, 0, 0 },
{ -1, -1, -1 }
});
/// <summary>
/// Initializes a new instance of the <see cref="PrewittProcessor{TColor}"/> class.
/// </summary>
public PrewittProcessor()
: base(PrewittX, PrewittY)
{
}
}
}