//
// 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 RobinsonProcessor : EdgeDetectorCompassProcessor
where TColor : struct, IPackedPixel, IEquatable
{
///
/// The North gradient operator
///
private static readonly Fast2DArray RobinsonNorth =
new float[,]
{
{ 1, 2, 1 },
{ 0, 0, 0 },
{ -1, -2, -1 }
};
///
/// The NorthWest gradient operator
///
private static readonly Fast2DArray RobinsonNorthWest =
new float[,]
{
{ 2, 1, 0 },
{ 1, 0, -1 },
{ 0, -1, -2 }
};
///
/// The West gradient operator
///
private static readonly Fast2DArray RobinsonWest =
new float[,]
{
{ 1, 0, -1 },
{ 2, 0, -2 },
{ 1, 0, -1 }
};
///
/// The SouthWest gradient operator
///
private static readonly Fast2DArray RobinsonSouthWest =
new float[,]
{
{ 0, -1, -2 },
{ 1, 0, -1 },
{ 2, 1, 0 }
};
///
/// The South gradient operator
///
private static readonly Fast2DArray RobinsonSouth =
new float[,]
{
{ -1, -2, -1 },
{ 0, 0, 0 },
{ 1, 2, 1 }
};
///
/// The SouthEast gradient operator
///
private static readonly Fast2DArray RobinsonSouthEast =
new float[,]
{
{ -2, -1, 0 },
{ -1, 0, 1 },
{ 0, 1, 2 }
};
///
/// The East gradient operator
///
private static readonly Fast2DArray RobinsonEast =
new float[,]
{
{ -1, 0, 1 },
{ -2, 0, 2 },
{ -1, 0, 1 }
};
///
/// The NorthEast gradient operator
///
private static readonly Fast2DArray RobinsonNorthEast =
new float[,]
{
{ 0, 1, 2 },
{ -1, 0, 1 },
{ -2, -1, 0 }
};
///
public override Fast2DArray North => RobinsonNorth;
///
public override Fast2DArray NorthWest => RobinsonNorthWest;
///
public override Fast2DArray West => RobinsonWest;
///
public override Fast2DArray SouthWest => RobinsonSouthWest;
///
public override Fast2DArray South => RobinsonSouth;
///
public override Fast2DArray SouthEast => RobinsonSouthEast;
///
public override Fast2DArray East => RobinsonEast;
///
public override Fast2DArray NorthEast => RobinsonNorthEast;
}
}