Browse Source

Move convolution filters

af/merge-core
James Jackson-South 10 years ago
parent
commit
40eceb2674
  1. 0
      src/ImageSharp/Filters/Convolution/BoxBlur.cs
  2. 0
      src/ImageSharp/Filters/Convolution/DetectEdges.cs
  3. 0
      src/ImageSharp/Filters/Convolution/GaussianBlur.cs
  4. 0
      src/ImageSharp/Filters/Convolution/GaussianSharpen.cs
  5. 0
      src/ImageSharp/Filters/Convolution/Options/EdgeDetection.cs
  6. 6
      src/ImageSharp/Filters/Processors/Convolution/BoxBlurProcessor.cs
  7. 13
      src/ImageSharp/Filters/Processors/Convolution/Convolution2DProcessor.cs
  8. 28
      src/ImageSharp/Filters/Processors/Convolution/Convolution2PassProcessor.cs
  9. 12
      src/ImageSharp/Filters/Processors/Convolution/ConvolutionProcessor.cs
  10. 8
      src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs
  11. 18
      src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs
  12. 10
      src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs
  13. 2
      src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/IEdgeDetectorSampler.cs
  14. 0
      src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs
  15. 0
      src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/KirschProcessor.cs
  16. 0
      src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs
  17. 0
      src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs
  18. 0
      src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs
  19. 0
      src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/PrewittProcessor.cs
  20. 0
      src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs
  21. 0
      src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs
  22. 0
      src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/ScharrProcessor.cs
  23. 0
      src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/SobelProcessor.cs
  24. 6
      src/ImageSharp/Filters/Processors/Convolution/GaussianBlurProcessor.cs
  25. 6
      src/ImageSharp/Filters/Processors/Convolution/GaussianSharpenProcessor.cs
  26. 3
      src/ImageSharp/Filters/Processors/Transforms/EntropyCropProcessor.cs
  27. 6
      tests/ImageSharp.Tests/Processors/Filters/DetectEdgesTest.cs
  28. 0
      tests/ImageSharp.Tests/Processors/Filters/EntropyCropTest.cs
  29. 0
      tests/ImageSharp.Tests/Processors/Filters/GaussianBlurTest.cs
  30. 0
      tests/ImageSharp.Tests/Processors/Filters/GaussianSharpenTest.cs

0
src/ImageSharp/Samplers/Convolution/BoxBlur.cs → src/ImageSharp/Filters/Convolution/BoxBlur.cs

0
src/ImageSharp/Samplers/Convolution/DetectEdges.cs → src/ImageSharp/Filters/Convolution/DetectEdges.cs

0
src/ImageSharp/Samplers/Convolution/GaussianBlur.cs → src/ImageSharp/Filters/Convolution/GaussianBlur.cs

0
src/ImageSharp/Samplers/Convolution/GaussianSharpen.cs → src/ImageSharp/Filters/Convolution/GaussianSharpen.cs

0
src/ImageSharp/Samplers/Convolution/Options/EdgeDetection.cs → src/ImageSharp/Filters/Convolution/Options/EdgeDetection.cs

6
src/ImageSharp/Samplers/Processors/Convolution/BoxBlurProcessor.cs → src/ImageSharp/Filters/Processors/Convolution/BoxBlurProcessor.cs

@ -10,7 +10,7 @@ namespace ImageSharp.Processors
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public class BoxBlurProcessor<TColor, TPacked> : ImageSamplingProcessor<TColor, TPacked>
public class BoxBlurProcessor<TColor, TPacked> : ImageFilteringProcessor<TColor, TPacked>
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
@ -43,9 +43,9 @@ namespace ImageSharp.Processors
public float[][] KernelY { get; }
/// <inheritdoc/>
public override void Apply(ImageBase<TColor, TPacked> target, ImageBase<TColor, TPacked> source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
protected override void Apply(ImageBase<TColor, TPacked> source, Rectangle sourceRectangle, int startY, int endY)
{
new Convolution2PassProcessor<TColor, TPacked>(this.KernelX, this.KernelY).Apply(target, source, targetRectangle, sourceRectangle, startY, endY);
new Convolution2PassProcessor<TColor, TPacked>(this.KernelX, this.KernelY).Apply(source, sourceRectangle);
}
/// <summary>

13
src/ImageSharp/Samplers/Processors/Convolution/Convolution2DProcessor.cs → src/ImageSharp/Filters/Processors/Convolution/Convolution2DProcessor.cs

@ -14,7 +14,7 @@ namespace ImageSharp.Processors
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public class Convolution2DProcessor<TColor, TPacked> : ImageSamplingProcessor<TColor, TPacked>
public class Convolution2DProcessor<TColor, TPacked> : ImageFilteringProcessor<TColor, TPacked>
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
@ -40,7 +40,7 @@ namespace ImageSharp.Processors
public float[][] KernelY { get; }
/// <inheritdoc/>
public override void Apply(ImageBase<TColor, TPacked> target, ImageBase<TColor, TPacked> source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
protected override void Apply(ImageBase<TColor, TPacked> source, Rectangle sourceRectangle, int startY, int endY)
{
int kernelYHeight = this.KernelY.Length;
int kernelYWidth = this.KernelY[0].Length;
@ -56,8 +56,10 @@ namespace ImageSharp.Processors
int maxY = sourceBottom - 1;
int maxX = endX - 1;
TColor[] target = new TColor[source.Width * source.Height];
using (PixelAccessor<TColor, TPacked> sourcePixels = source.Lock())
using (PixelAccessor<TColor, TPacked> targetPixels = target.Lock())
using (PixelAccessor<TColor, TPacked> targetPixels = target.Lock<TColor, TPacked>(source.Width, source.Height))
{
Parallel.For(
startY,
@ -116,14 +118,15 @@ namespace ImageSharp.Processors
float green = (float)Math.Sqrt((gX * gX) + (gY * gY));
float blue = (float)Math.Sqrt((bX * bX) + (bY * bY));
Vector4 targetColor = targetPixels[x, y].ToVector4();
TColor packed = default(TColor);
packed.PackFromVector4(new Vector4(red, green, blue, targetColor.Z));
packed.PackFromVector4(new Vector4(red, green, blue, sourcePixels[x, y].ToVector4().W));
targetPixels[x, y] = packed;
}
}
});
}
source.SetPixels(source.Width, source.Height, target);
}
}
}

28
src/ImageSharp/Samplers/Processors/Convolution/Convolution2PassProcessor.cs → src/ImageSharp/Filters/Processors/Convolution/Convolution2PassProcessor.cs

@ -13,7 +13,7 @@ namespace ImageSharp.Processors
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public class Convolution2PassProcessor<TColor, TPacked> : ImageSamplingProcessor<TColor, TPacked>
public class Convolution2PassProcessor<TColor, TPacked> : ImageFilteringProcessor<TColor, TPacked>
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
@ -39,29 +39,37 @@ namespace ImageSharp.Processors
public float[][] KernelY { get; }
/// <inheritdoc/>
public override void Apply(ImageBase<TColor, TPacked> target, ImageBase<TColor, TPacked> source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
protected override void Apply(ImageBase<TColor, TPacked> source, Rectangle sourceRectangle, int startY, int endY)
{
float[][] kernelX = this.KernelX;
float[][] kernelY = this.KernelY;
int width = source.Width;
int height = source.Height;
ImageBase<TColor, TPacked> firstPass = new Image<TColor, TPacked>(source.Width, source.Height);
this.ApplyConvolution(firstPass, source, sourceRectangle, startY, endY, kernelX);
this.ApplyConvolution(target, firstPass, sourceRectangle, startY, endY, kernelY);
TColor[] target = new TColor[width * height];
TColor[] firstPass = new TColor[width * height];
this.ApplyConvolution(width, height, firstPass, source.Pixels, sourceRectangle, startY, endY, kernelX);
this.ApplyConvolution(width, height, target, firstPass, sourceRectangle, startY, endY, kernelY);
source.SetPixels(width, height, target);
}
/// <summary>
/// Applies the process to the specified portion of the specified <see cref="ImageBase{TColor, TPacked}"/> at the specified location
/// and with the specified size.
/// </summary>
/// <param name="target">Target image to apply the process to.</param>
/// <param name="source">The source image. Cannot be null.</param>
/// <param name="width">The image width.</param>
/// <param name="height">The image height.</param>
/// <param name="target">The target pixels to apply the process to.</param>
/// <param name="source">The source pixels. Cannot be null.</param>
/// <param name="sourceRectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to draw.
/// </param>
/// <param name="startY">The index of the row within the source image to start processing.</param>
/// <param name="endY">The index of the row within the source image to end processing.</param>
/// <param name="kernel">The kernel operator.</param>
private void ApplyConvolution(ImageBase<TColor, TPacked> target, ImageBase<TColor, TPacked> source, Rectangle sourceRectangle, int startY, int endY, float[][] kernel)
private void ApplyConvolution(int width, int height, TColor[] target, TColor[] source, Rectangle sourceRectangle, int startY, int endY, float[][] kernel)
{
int kernelHeight = kernel.Length;
int kernelWidth = kernel[0].Length;
@ -74,8 +82,8 @@ namespace ImageSharp.Processors
int maxY = sourceBottom - 1;
int maxX = endX - 1;
using (PixelAccessor<TColor, TPacked> sourcePixels = source.Lock())
using (PixelAccessor<TColor, TPacked> targetPixels = target.Lock())
using (PixelAccessor<TColor, TPacked> sourcePixels = source.Lock<TColor, TPacked>(width, height))
using (PixelAccessor<TColor, TPacked> targetPixels = target.Lock<TColor, TPacked>(width, height))
{
Parallel.For(
startY,

12
src/ImageSharp/Samplers/Processors/Convolution/ConvolutionProcessor.cs → src/ImageSharp/Filters/Processors/Convolution/ConvolutionProcessor.cs

@ -13,7 +13,7 @@ namespace ImageSharp.Processors
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public class ConvolutionProcessor<TColor, TPacked> : ImageSamplingProcessor<TColor, TPacked>
public class ConvolutionProcessor<TColor, TPacked> : ImageFilteringProcessor<TColor, TPacked>
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
@ -32,7 +32,7 @@ namespace ImageSharp.Processors
public virtual float[][] KernelXY { get; }
/// <inheritdoc/>
public override void Apply(ImageBase<TColor, TPacked> target, ImageBase<TColor, TPacked> source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
protected override void Apply(ImageBase<TColor, TPacked> source, Rectangle sourceRectangle, int startY, int endY)
{
float[][] kernelX = this.KernelXY;
int kernelLength = kernelX.GetLength(0);
@ -45,8 +45,9 @@ namespace ImageSharp.Processors
int maxY = sourceBottom - 1;
int maxX = endX - 1;
TColor[] target = new TColor[source.Width * source.Height];
using (PixelAccessor<TColor, TPacked> sourcePixels = source.Lock())
using (PixelAccessor<TColor, TPacked> targetPixels = target.Lock())
using (PixelAccessor<TColor, TPacked> targetPixels = target.Lock<TColor, TPacked>(source.Width, source.Height))
{
Parallel.For(
startY,
@ -92,14 +93,15 @@ namespace ImageSharp.Processors
float green = gX;
float blue = bX;
Vector4 targetColor = targetPixels[x, y].ToVector4();
TColor packed = default(TColor);
packed.PackFromVector4(new Vector4(red, green, blue, targetColor.Z));
packed.PackFromVector4(new Vector4(red, green, blue, sourcePixels[x, y].ToVector4().W));
targetPixels[x, y] = packed;
}
}
});
}
source.SetPixels(source.Width, source.Height, target);
}
}
}

8
src/ImageSharp/Samplers/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs → src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs

@ -10,7 +10,7 @@ namespace ImageSharp.Processors
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public abstract class EdgeDetector2DProcessor<TColor, TPacked> : ImageSamplingProcessor<TColor, TPacked>, IEdgeDetectorProcessor<TColor, TPacked>
public abstract class EdgeDetector2DProcessor<TColor, TPacked> : ImageFilteringProcessor<TColor, TPacked>, IEdgeDetectorProcessor<TColor, TPacked>
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
@ -28,13 +28,13 @@ namespace ImageSharp.Processors
public bool Grayscale { get; set; }
/// <inheritdoc />
public override void Apply(ImageBase<TColor, TPacked> target, ImageBase<TColor, TPacked> source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
protected override void Apply(ImageBase<TColor, TPacked> source, Rectangle sourceRectangle, int startY, int endY)
{
new Convolution2DProcessor<TColor, TPacked>(this.KernelX, this.KernelY).Apply(target, source, targetRectangle, sourceRectangle, startY, endY);
new Convolution2DProcessor<TColor, TPacked>(this.KernelX, this.KernelY).Apply(source, sourceRectangle);
}
/// <inheritdoc/>
protected override void OnApply(ImageBase<TColor, TPacked> target, ImageBase<TColor, TPacked> source, Rectangle targetRectangle, Rectangle sourceRectangle)
protected override void OnApply(ImageBase<TColor, TPacked> source, Rectangle sourceRectangle)
{
if (this.Grayscale)
{

18
src/ImageSharp/Samplers/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs → src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs

@ -14,7 +14,7 @@ namespace ImageSharp.Processors
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public abstract class EdgeDetectorCompassProcessor<TColor, TPacked> : ImageSamplingProcessor<TColor, TPacked>, IEdgeDetectorProcessor<TColor, TPacked>
public abstract class EdgeDetectorCompassProcessor<TColor, TPacked> : ImageFilteringProcessor<TColor, TPacked>, IEdgeDetectorProcessor<TColor, TPacked>
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
@ -62,7 +62,7 @@ namespace ImageSharp.Processors
public bool Grayscale { get; set; }
/// <inheritdoc />
public override void Apply(ImageBase<TColor, TPacked> target, ImageBase<TColor, TPacked> source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
protected override void Apply(ImageBase<TColor, TPacked> source, Rectangle sourceRectangle, int startY, int endY)
{
float[][][] kernels = { this.North, this.NorthWest, this.West, this.SouthWest, this.South, this.SouthEast, this.East, this.NorthEast };
@ -76,7 +76,9 @@ namespace ImageSharp.Processors
int maxY = Math.Min(source.Height, endY);
// First run.
new ConvolutionProcessor<TColor, TPacked>(kernels[0]).Apply(target, source, targetRectangle, sourceRectangle, startY, endY);
ImageBase<TColor, TPacked> target = new Image<TColor, TPacked>(source.Width, source.Height);
target.ClonePixels(source.Width, source.Height, source.Pixels);
new ConvolutionProcessor<TColor, TPacked>(kernels[0]).Apply(target, sourceRectangle);
if (kernels.Length == 1)
{
@ -98,10 +100,14 @@ namespace ImageSharp.Processors
}
// Additional runs.
// ReSharper disable once ForCanBeConvertedToForeach
for (int i = 1; i < kernels.Length; i++)
{
// Create a clone for each pass and copy the offset pixels across.
ImageBase<TColor, TPacked> pass = new Image<TColor, TPacked>(source.Width, source.Height);
new ConvolutionProcessor<TColor, TPacked>(kernels[i]).Apply(pass, source, sourceRectangle, targetRectangle, startY, endY);
pass.ClonePixels(source.Width, source.Height, source.Pixels);
new ConvolutionProcessor<TColor, TPacked>(kernels[i]).Apply(pass, sourceRectangle);
using (PixelAccessor<TColor, TPacked> passPixels = pass.Lock())
using (PixelAccessor<TColor, TPacked> targetPixels = target.Lock())
@ -125,10 +131,12 @@ namespace ImageSharp.Processors
});
}
}
source.SetPixels(source.Width, source.Height, target.Pixels);
}
/// <inheritdoc/>
protected override void OnApply(ImageBase<TColor, TPacked> target, ImageBase<TColor, TPacked> source, Rectangle targetRectangle, Rectangle sourceRectangle)
protected override void OnApply(ImageBase<TColor, TPacked> source, Rectangle sourceRectangle)
{
if (this.Grayscale)
{

10
src/ImageSharp/Samplers/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs → src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs

@ -10,7 +10,7 @@ namespace ImageSharp.Processors
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public abstract class EdgeDetectorProcessor<TColor, TPacked> : ImageSamplingProcessor<TColor, TPacked>, IEdgeDetectorProcessor<TColor, TPacked>
public abstract class EdgeDetectorProcessor<TColor, TPacked> : ImageFilteringProcessor<TColor, TPacked>, IEdgeDetectorProcessor<TColor, TPacked>
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
@ -23,13 +23,13 @@ namespace ImageSharp.Processors
public abstract float[][] KernelXY { get; }
/// <inheritdoc/>
public override void Apply(ImageBase<TColor, TPacked> target, ImageBase<TColor, TPacked> source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
protected override void Apply(ImageBase<TColor, TPacked> source, Rectangle sourceRectangle, int startY, int endY)
{
new ConvolutionProcessor<TColor, TPacked>(this.KernelXY).Apply(target, source, targetRectangle, sourceRectangle, startY, endY);
new ConvolutionProcessor<TColor, TPacked>(this.KernelXY).Apply(source, sourceRectangle);
}
/// <inheritdoc/>
protected override void OnApply(ImageBase<TColor, TPacked> target, ImageBase<TColor, TPacked> source, Rectangle targetRectangle, Rectangle sourceRectangle)
protected override void OnApply(ImageBase<TColor, TPacked> source, Rectangle sourceRectangle)
{
if (this.Grayscale)
{
@ -37,4 +37,4 @@ namespace ImageSharp.Processors
}
}
}
}
}

2
src/ImageSharp/Samplers/Processors/Convolution/EdgeDetection/IEdgeDetectorSampler.cs → src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/IEdgeDetectorSampler.cs

@ -10,7 +10,7 @@ namespace ImageSharp.Processors
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public interface IEdgeDetectorProcessor<TColor, TPacked> : IImageSamplingProcessor<TColor, TPacked>, IEdgeDetectorProcessor
public interface IEdgeDetectorProcessor<TColor, TPacked> : IImageFilteringProcessor<TColor, TPacked>, IEdgeDetectorProcessor
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{

0
src/ImageSharp/Samplers/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs → src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs

0
src/ImageSharp/Samplers/Processors/Convolution/EdgeDetection/KirschProcessor.cs → src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/KirschProcessor.cs

0
src/ImageSharp/Samplers/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs → src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs

0
src/ImageSharp/Samplers/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs → src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs

0
src/ImageSharp/Samplers/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs → src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs

0
src/ImageSharp/Samplers/Processors/Convolution/EdgeDetection/PrewittProcessor.cs → src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/PrewittProcessor.cs

0
src/ImageSharp/Samplers/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs → src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs

0
src/ImageSharp/Samplers/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs → src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs

0
src/ImageSharp/Samplers/Processors/Convolution/EdgeDetection/ScharrProcessor.cs → src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/ScharrProcessor.cs

0
src/ImageSharp/Samplers/Processors/Convolution/EdgeDetection/SobelProcessor.cs → src/ImageSharp/Filters/Processors/Convolution/EdgeDetection/SobelProcessor.cs

6
src/ImageSharp/Samplers/Processors/Convolution/GaussianBlurProcessor.cs → src/ImageSharp/Filters/Processors/Convolution/GaussianBlurProcessor.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Processors
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public class GaussianBlurProcessor<TColor, TPacked> : ImageSamplingProcessor<TColor, TPacked>
public class GaussianBlurProcessor<TColor, TPacked> : ImageFilteringProcessor<TColor, TPacked>
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
@ -81,9 +81,9 @@ namespace ImageSharp.Processors
public float[][] KernelY { get; }
/// <inheritdoc/>
public override void Apply(ImageBase<TColor, TPacked> target, ImageBase<TColor, TPacked> source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
protected override void Apply(ImageBase<TColor, TPacked> source, Rectangle sourceRectangle, int startY, int endY)
{
new Convolution2PassProcessor<TColor, TPacked>(this.KernelX, this.KernelY).Apply(target, source, targetRectangle, sourceRectangle, startY, endY);
new Convolution2PassProcessor<TColor, TPacked>(this.KernelX, this.KernelY).Apply(source, sourceRectangle);
}
/// <summary>

6
src/ImageSharp/Samplers/Processors/Convolution/GaussianSharpenProcessor.cs → src/ImageSharp/Filters/Processors/Convolution/GaussianSharpenProcessor.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Processors
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public class GaussianSharpenProcessor<TColor, TPacked> : ImageSamplingProcessor<TColor, TPacked>
public class GaussianSharpenProcessor<TColor, TPacked> : ImageFilteringProcessor<TColor, TPacked>
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
@ -83,9 +83,9 @@ namespace ImageSharp.Processors
public float[][] KernelY { get; }
/// <inheritdoc/>
public override void Apply(ImageBase<TColor, TPacked> target, ImageBase<TColor, TPacked> source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
protected override void Apply(ImageBase<TColor, TPacked> source, Rectangle sourceRectangle, int startY, int endY)
{
new Convolution2PassProcessor<TColor, TPacked>(this.KernelX, this.KernelY).Apply(target, source, targetRectangle, sourceRectangle, startY, endY);
new Convolution2PassProcessor<TColor, TPacked>(this.KernelX, this.KernelY).Apply(source, sourceRectangle);
}
/// <summary>

3
src/ImageSharp/Filters/Processors/Transforms/EntropyCropProcessor.cs

@ -37,9 +37,10 @@ namespace ImageSharp.Processors
protected override void Apply(ImageBase<TColor, TPacked> source, Rectangle sourceRectangle, int startY, int endY)
{
ImageBase<TColor, TPacked> temp = new Image<TColor, TPacked>(source.Width, source.Height);
temp.ClonePixels(source.Width, source.Height, source.Pixels);
// Detect the edges.
new SobelProcessor<TColor, TPacked>().Apply(temp, source, sourceRectangle);
new SobelProcessor<TColor, TPacked>().Apply(temp, sourceRectangle);
// Apply threshold binarization filter.
new BinaryThresholdProcessor<TColor, TPacked>(this.Value).Apply(temp, sourceRectangle);

6
tests/ImageSharp.Tests/Processors/Samplers/DetectEdgesTest.cs → tests/ImageSharp.Tests/Processors/Filters/DetectEdgesTest.cs

@ -23,7 +23,7 @@ namespace ImageSharp.Tests
EdgeDetection.RobertsCross,
EdgeDetection.Robinson,
EdgeDetection.Scharr,
EdgeDetection.Sobel,
EdgeDetection.Sobel
};
[Theory]
@ -40,7 +40,7 @@ namespace ImageSharp.Tests
using (FileStream output = File.OpenWrite($"{path}/{filename}"))
{
image.DetectEdges(detector)
.Save(output);
.Save(output);
}
}
}
@ -59,7 +59,7 @@ namespace ImageSharp.Tests
using (FileStream output = File.OpenWrite($"{path}/{filename}"))
{
image.DetectEdges(detector, new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2))
.Save(output);
.Save(output);
}
}
}

0
tests/ImageSharp.Tests/Processors/Samplers/EntropyCropTest.cs → tests/ImageSharp.Tests/Processors/Filters/EntropyCropTest.cs

0
tests/ImageSharp.Tests/Processors/Samplers/GaussianBlurTest.cs → tests/ImageSharp.Tests/Processors/Filters/GaussianBlurTest.cs

0
tests/ImageSharp.Tests/Processors/Samplers/GaussianSharpenTest.cs → tests/ImageSharp.Tests/Processors/Filters/GaussianSharpenTest.cs

Loading…
Cancel
Save