Browse Source

Adding more operators

Former-commit-id: c7a21e360951af3de40b7e90291858f4db798724
af/merge-core
James South 12 years ago
parent
commit
6244288890
  1. 3
      src/ImageProcessor/ImageProcessor.csproj
  2. 68
      src/ImageProcessor/Imaging/EdgeDetection/CostellaEdgeFilter.cs
  3. 52
      src/ImageProcessor/Imaging/EdgeDetection/KayyaliEdgeFilter.cs
  4. 52
      src/ImageProcessor/Imaging/EdgeDetection/KirschEdgeFilter.cs
  5. 4
      src/ImageProcessor/Imaging/FastBitmap.cs
  6. 1
      src/ImageProcessor/Settings.StyleCop
  7. 2
      src/ImageProcessorConsole/Program.cs

3
src/ImageProcessor/ImageProcessor.csproj

@ -78,10 +78,11 @@
<Compile Include="Imaging\Colors\YCbCrColor.cs" />
<Compile Include="Imaging\EdgeDetection\ConvolutionFilter.cs" />
<Compile Include="Imaging\EdgeDetection\IEdgeFilter.cs" />
<Compile Include="Imaging\EdgeDetection\KirschEdgeFilter.cs" />
<Compile Include="Imaging\EdgeDetection\ScharrEdgeFilter.cs" />
<Compile Include="Imaging\EdgeDetection\RobertsCrossEdgeFilter.cs" />
<Compile Include="Imaging\EdgeDetection\PrewittEdgeFilter.cs" />
<Compile Include="Imaging\EdgeDetection\CostellaEdgeFilter.cs" />
<Compile Include="Imaging\EdgeDetection\KayyaliEdgeFilter.cs" />
<Compile Include="Imaging\EdgeDetection\SobelEdgeFilter.cs" />
<Compile Include="Imaging\FastBitmap.cs">
<SubType>Code</SubType>

68
src/ImageProcessor/Imaging/EdgeDetection/CostellaEdgeFilter.cs

@ -1,68 +0,0 @@
// --------------------------------------------------------------------------------------------------------------------
// <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 }
};
}
}
}
}

52
src/ImageProcessor/Imaging/EdgeDetection/KayyaliEdgeFilter.cs

@ -0,0 +1,52 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="KayyaliEdgeFilter.cs" company="James South">
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// The Kayyali operator filter.
// <see href="http://edgedetection.webs.com/" />
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Imaging.EdgeDetection
{
/// <summary>
/// The Kayyali operator filter.
/// <see href="http://edgedetection.webs.com/"/>
/// </summary>
public class KayyaliEdgeFilter : IEdgeFilter
{
/// <summary>
/// Gets the horizontal gradient operator.
/// </summary>
public double[,] HorizontalGradientOperator
{
get
{
return new double[,]
{
{ 6, 0, -6 },
{ 0, 0, 0 },
{ -6, 0, 6 }
};
}
}
/// <summary>
/// Gets the vertical gradient operator.
/// </summary>
public double[,] VerticalGradientOperator
{
get
{
return new double[,]
{
{ -6, 0, 6 },
{ 0, 0, 0 },
{ 6, 0, -6 }
};
}
}
}
}

52
src/ImageProcessor/Imaging/EdgeDetection/KirschEdgeFilter.cs

@ -0,0 +1,52 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="KirschEdgeFilter.cs" company="James South">
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// The Kirsch operator filter.
// <see href="http://en.wikipedia.org/wiki/Kirsch_operator" />
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Imaging.EdgeDetection
{
/// <summary>
/// The Kirsch operator filter.
/// <see href="http://en.wikipedia.org/wiki/Kirsch_operator"/>
/// </summary>
public class KirschEdgeFilter : IEdgeFilter
{
/// <summary>
/// Gets the horizontal gradient operator.
/// </summary>
public double[,] HorizontalGradientOperator
{
get
{
return new double[,]
{
{ 5, 5, 5 },
{ -3, 0, -3 },
{ -3, -3, -3 }
};
}
}
/// <summary>
/// Gets the vertical gradient operator.
/// </summary>
public double[,] VerticalGradientOperator
{
get
{
return new double[,]
{
{ 5, -3, -3 },
{ 5, 0, -3 },
{ 5, -3, -3 }
};
}
}
}
}

4
src/ImageProcessor/Imaging/FastBitmap.cs

@ -156,12 +156,12 @@ namespace ImageProcessor.Imaging
/// <returns>The <see cref="System.Drawing.Color"/> at the given pixel.</returns>
public Color GetPixel(int x, int y)
{
if ((x < 0) || (x > this.width))
if ((x < 0) || (x >= this.width))
{
throw new ArgumentOutOfRangeException("x", "Value cannot be less than zero or greater than the bitmap width.");
}
if ((y < 0) || (y > this.height))
if ((y < 0) || (y >= this.height))
{
throw new ArgumentOutOfRangeException("y", "Value cannot be less than zero or greater than the bitmap height.");
}

1
src/ImageProcessor/Settings.StyleCop

@ -6,6 +6,7 @@
<Value>ddd</Value>
<Value>dllimport</Value>
<Value>gps</Value>
<Value>Kayyali</Value>
<Value>mmmm</Value>
<Value>orig</Value>
<Value>Scharr</Value>

2
src/ImageProcessorConsole/Program.cs

@ -77,7 +77,7 @@ namespace ImageProcessorConsole
//.Constrain(size)
//.ReplaceColor(Color.FromArgb(255, 1, 107, 165), Color.FromArgb(255, 1, 165, 13), 80)
.Resize(layer)
.DetectEdges(new PrewittEdgeFilter(), false)
.DetectEdges(new KirschEdgeFilter())
//.Filter(MatrixFilters.Comic)
//.Filter(MatrixFilters.HiSatch)
//.Pixelate(8)

Loading…
Cancel
Save