mirror of https://github.com/SixLabors/ImageSharp
Browse Source
TODO: Fix range in loop Former-commit-id: fa7787210a29818d5ad89dde70bd1743ab1e2273af/merge-core
23 changed files with 465 additions and 65 deletions
@ -0,0 +1,68 @@ |
|||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
// <copyright file="CostellaEdgeFilter.cs" company="James South">
|
||||
|
// Copyright (c) James South.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
// <summary>
|
||||
|
// The Costella operator filter.
|
||||
|
// <see href="http://johncostella.com/edgedetect/" />
|
||||
|
// </summary>
|
||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace ImageProcessor.Imaging.EdgeDetection |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// The Costella operator filter.
|
||||
|
/// <see href="http://johncostella.com/edgedetect/"/>
|
||||
|
/// </summary>
|
||||
|
public class CostellaEdgeFilter : IEdgeFilter |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Gets the horizontal gradient operator.
|
||||
|
/// </summary>
|
||||
|
public double[,] HorizontalGradientOperator |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return new double[,] |
||||
|
{ { -1, -1, -1, -1, -1, }, |
||||
|
{ -1, -1, -1, -1, -1, }, |
||||
|
{ -1, -1, 24, -1, -1, }, |
||||
|
{ -1, -1, -1, -1, -1, }, |
||||
|
{ -1, -1, -1, -1, -1 }, }; |
||||
|
return new double[,] |
||||
|
{ |
||||
|
{ -1, -3, 0, 3, 1 }, |
||||
|
{ -1, -3, 0, 3, 1 }, |
||||
|
{ -1, -3, 0, 3, 1 }, |
||||
|
{ -1, -3, 0, 3, 1 }, |
||||
|
{ -1, -3, 0, 3, 1 } |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets the vertical gradient operator.
|
||||
|
/// </summary>
|
||||
|
public double[,] VerticalGradientOperator |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return new double[,] |
||||
|
{ { -1, -1, -1, -1, -1, }, |
||||
|
{ -1, -1, -1, -1, -1, }, |
||||
|
{ -1, -1, 24, -1, -1, }, |
||||
|
{ -1, -1, -1, -1, -1, }, |
||||
|
{ -1, -1, -1, -1, -1 }, }; |
||||
|
return new double[,] |
||||
|
{ |
||||
|
{ 1, 1, 1, 1, 1 }, |
||||
|
{ 3, 3, 3, 3, 3 }, |
||||
|
{ 0, 0, 0, 0, 0 }, |
||||
|
{ -3, -3, -3, -3, -3 }, |
||||
|
{ -1, -1, -1, -1, -1 } |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,9 +1,28 @@ |
|||||
namespace ImageProcessor.Imaging.EdgeDetection |
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
// <copyright file="IEdgeFilter.cs" company="James South">
|
||||
|
// Copyright (c) James South.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
// <summary>
|
||||
|
// Describes properties for creating edge detection filters.
|
||||
|
// </summary>
|
||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace ImageProcessor.Imaging.EdgeDetection |
||||
{ |
{ |
||||
|
/// <summary>
|
||||
|
/// Describes properties for creating edge detection filters.
|
||||
|
/// </summary>
|
||||
public interface IEdgeFilter |
public interface IEdgeFilter |
||||
{ |
{ |
||||
double[,] HorizontalMatrix { get; } |
/// <summary>
|
||||
|
/// Gets the horizontal gradient operator.
|
||||
|
/// </summary>
|
||||
|
double[,] HorizontalGradientOperator { get; } |
||||
|
|
||||
double[,] VerticalMatrix { get; } |
/// <summary>
|
||||
|
/// Gets the vertical gradient operator.
|
||||
|
/// </summary>
|
||||
|
double[,] VerticalGradientOperator { get; } |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,52 @@ |
|||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
// <copyright file="PrewittEdgeFilter.cs" company="James South">
|
||||
|
// Copyright (c) James South.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
// <summary>
|
||||
|
// The Prewitt operator filter.
|
||||
|
// <see href="http://en.wikipedia.org/wiki/Prewitt_operator" />
|
||||
|
// </summary>
|
||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace ImageProcessor.Imaging.EdgeDetection |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// The Prewitt operator filter.
|
||||
|
/// <see href="http://en.wikipedia.org/wiki/Prewitt_operator"/>
|
||||
|
/// </summary>
|
||||
|
public class PrewittEdgeFilter : IEdgeFilter |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Gets the horizontal gradient operator.
|
||||
|
/// </summary>
|
||||
|
public double[,] HorizontalGradientOperator |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return new double[,] |
||||
|
{ |
||||
|
{ -1, 0, 1 }, |
||||
|
{ -1, 0, 1 }, |
||||
|
{ -1, 0, 1 } |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets the vertical gradient operator.
|
||||
|
/// </summary>
|
||||
|
public double[,] VerticalGradientOperator |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return new double[,] |
||||
|
{ |
||||
|
{ 1, 1, 1 }, |
||||
|
{ 0, 0, 0 }, |
||||
|
{ -1, -1, -1 } |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,50 @@ |
|||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
// <copyright file="RobertsCrossEdgeFilter.cs" company="James South">
|
||||
|
// Copyright (c) James South.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
// <summary>
|
||||
|
// The Roberts Cross operator filter.
|
||||
|
// <see href="http://en.wikipedia.org/wiki/Roberts_cross" />
|
||||
|
// </summary>
|
||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace ImageProcessor.Imaging.EdgeDetection |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// The Roberts Cross operator filter.
|
||||
|
/// <see href="http://en.wikipedia.org/wiki/Roberts_cross"/>
|
||||
|
/// </summary>
|
||||
|
public class RobertsCrossEdgeFilter : IEdgeFilter |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Gets the horizontal gradient operator.
|
||||
|
/// </summary>
|
||||
|
public double[,] HorizontalGradientOperator |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return new double[,] |
||||
|
{ |
||||
|
{ 1, 0 }, |
||||
|
{ 0, -1 } |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets the vertical gradient operator.
|
||||
|
/// </summary>
|
||||
|
public double[,] VerticalGradientOperator |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return new double[,] |
||||
|
{ |
||||
|
{ 0, 1 }, |
||||
|
{ -1, 0 } |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,52 @@ |
|||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
// <copyright file="ScharrEdgeFilter.cs" company="James South">
|
||||
|
// Copyright (c) James South.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
// <summary>
|
||||
|
// The Scharr operator filter.
|
||||
|
// <see href="http://en.wikipedia.org/wiki/Sobel_operator#Alternative_operators" />
|
||||
|
// </summary>
|
||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace ImageProcessor.Imaging.EdgeDetection |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// The Scharr operator filter.
|
||||
|
/// <see href="http://en.wikipedia.org/wiki/Sobel_operator#Alternative_operators"/>
|
||||
|
/// </summary>
|
||||
|
public class ScharrEdgeFilter : IEdgeFilter |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Gets the horizontal gradient operator.
|
||||
|
/// </summary>
|
||||
|
public double[,] HorizontalGradientOperator |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return new double[,] |
||||
|
{ |
||||
|
{ -3, 0, 3 }, |
||||
|
{ -10, 0, 10 }, |
||||
|
{ -3, 0, 3 } |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets the vertical gradient operator.
|
||||
|
/// </summary>
|
||||
|
public double[,] VerticalGradientOperator |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return new double[,] |
||||
|
{ |
||||
|
{ 3, 10, 3 }, |
||||
|
{ 0, 0, 0 }, |
||||
|
{ -3, -10, -3 } |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
93b93eade2c7697a0a8fe9363d493a8a59de245a |
||||
@ -0,0 +1 @@ |
|||||
|
bdff6764fd5c4e3054ba7d8c43cc8c29be0e6f5e |
||||
@ -0,0 +1,3 @@ |
|||||
|
version https://git-lfs.github.com/spec/v1 |
||||
|
oid sha256:2dd59c277b646f15b0223c028ddfb0fa7d5edcb2609882e2c6841e5b2714cd67 |
||||
|
size 3182 |
||||
@ -0,0 +1,3 @@ |
|||||
|
version https://git-lfs.github.com/spec/v1 |
||||
|
oid sha256:7eb6df312d356346d0d7f5d55c657a4a3a08f11d293c93f56447137a49190d0f |
||||
|
size 17319 |
||||
@ -0,0 +1,3 @@ |
|||||
|
version https://git-lfs.github.com/spec/v1 |
||||
|
oid sha256:8d74259c087adb38c335a3162c56f1c3ae344e098f2471d79d702d80a95907a3 |
||||
|
size 4066 |
||||
@ -0,0 +1,3 @@ |
|||||
|
version https://git-lfs.github.com/spec/v1 |
||||
|
oid sha256:343794bc824674c81cd8ba90acd3bb690d43c84d363e3375e8ee42207867f977 |
||||
|
size 7011 |
||||
@ -0,0 +1,3 @@ |
|||||
|
version https://git-lfs.github.com/spec/v1 |
||||
|
oid sha256:662cd66659e03b0ca18e62d2e9bdc69e62e082fad9a0316348db031f67092497 |
||||
|
size 4407 |
||||
@ -0,0 +1 @@ |
|||||
|
ef1fdff21802713450cf2f81321c0605962ec6f5 |
||||
@ -0,0 +1 @@ |
|||||
|
fad7e5225f13c9d35d9e877c93e2bb44da7404c0 |
||||
Loading…
Reference in new issue