//
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
//
namespace ImageSharp.Processing.Processors
{
using System;
using System.Diagnostics.CodeAnalysis;
///
/// The Kirsch operator filter.
///
///
/// The pixel format.
[SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")]
public class KirschProcessor : EdgeDetectorCompassProcessor
where TColor : struct, IPackedPixel, IEquatable
{
///
/// The North gradient operator
///
private static readonly Fast2DArray KirschNorth =
new float[,]
{
{ 5, 5, 5 },
{ -3, 0, -3 },
{ -3, -3, -3 }
};
///
/// The NorthWest gradient operator
///
private static readonly Fast2DArray KirschNorthWest =
new float[,]
{
{ 5, 5, -3 },
{ 5, 0, -3 },
{ -3, -3, -3 }
};
///
/// The West gradient operator
///
private static readonly Fast2DArray KirschWest =
new float[,]
{
{ 5, -3, -3 },
{ 5, 0, -3 },
{ 5, -3, -3 }
};
///
/// The SouthWest gradient operator
///
private static readonly Fast2DArray KirschSouthWest =
new float[,]
{
{ -3, -3, -3 },
{ 5, 0, -3 },
{ 5, 5, -3 }
};
///
/// The South gradient operator
///
private static readonly Fast2DArray KirschSouth =
new float[,]
{
{ -3, -3, -3 },
{ -3, 0, -3 },
{ 5, 5, 5 }
};
///
/// The SouthEast gradient operator
///
private static readonly Fast2DArray KirschSouthEast =
new float[,]
{
{ -3, -3, -3 },
{ -3, 0, 5 },
{ -3, 5, 5 }
};
///
/// The East gradient operator
///
private static readonly Fast2DArray KirschEast =
new float[,]
{
{ -3, -3, 5 },
{ -3, 0, 5 },
{ -3, -3, 5 }
};
///
/// The NorthEast gradient operator
///
private static readonly Fast2DArray KirschNorthEast =
new float[,]
{
{ -3, 5, 5 },
{ -3, 0, 5 },
{ -3, -3, -3 }
};
///
public override Fast2DArray North => KirschNorth;
///
public override Fast2DArray NorthWest => KirschNorthWest;
///
public override Fast2DArray West => KirschWest;
///
public override Fast2DArray SouthWest => KirschSouthWest;
///
public override Fast2DArray South => KirschSouth;
///
public override Fast2DArray SouthEast => KirschSouthEast;
///
public override Fast2DArray East => KirschEast;
///
public override Fast2DArray NorthEast => KirschNorthEast;
}
}