mirror of https://github.com/SixLabors/ImageSharp
8 changed files with 85 additions and 115 deletions
@ -0,0 +1,56 @@ |
|||
// // Copyright (c) Six Labors and contributors.
|
|||
// // Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
using SixLabors.ImageSharp.Processing; |
|||
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; |
|||
using SixLabors.Primitives; |
|||
|
|||
using Xunit; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution |
|||
{ |
|||
[GroupOutput("Convolution")] |
|||
public abstract class Basic1ParameterConvolutionTests |
|||
{ |
|||
private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.05F); |
|||
|
|||
public static readonly TheoryData<int> Values = new TheoryData<int> { 3, 5 }; |
|||
|
|||
public static readonly string[] InputImages = |
|||
{ |
|||
TestImages.Bmp.Car, |
|||
TestImages.Png.CalliphoraPartial |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(InputImages), nameof(Values), PixelTypes.Rgba32)] |
|||
public void OnFullImage<TPixel>(TestImageProvider<TPixel> provider, int value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
provider.Utility.TestGroupName = this.GetType().Name; |
|||
provider.RunValidatingProcessorTest( |
|||
x => this.Apply(x, value), |
|||
value, |
|||
ValidatorComparer); |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(InputImages), nameof(Values), PixelTypes.Rgba32)] |
|||
public void InBox<TPixel>(TestImageProvider<TPixel> provider, int value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
provider.Utility.TestGroupName = this.GetType().Name; |
|||
provider.RunRectangleConstrainedValidatingProcessorTest( |
|||
(x, rect) => this.Apply(x, value, rect), |
|||
value, |
|||
ValidatorComparer); |
|||
} |
|||
|
|||
protected abstract void Apply<TPixel>(IImageProcessingContext<TPixel> ctx, int value) |
|||
where TPixel : struct, IPixel<TPixel>; |
|||
|
|||
protected abstract void Apply<TPixel>(IImageProcessingContext<TPixel> ctx, int value, Rectangle bounds) |
|||
where TPixel : struct, IPixel<TPixel>; |
|||
} |
|||
} |
|||
@ -1,51 +1,17 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
using SixLabors.ImageSharp.Processing; |
|||
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; |
|||
|
|||
using SixLabors.Primitives; |
|||
using Xunit; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution |
|||
{ |
|||
public class BoxBlurTest : FileTestBase |
|||
[GroupOutput("Convolution")] |
|||
public class BoxBlurTest : Basic1ParameterConvolutionTests |
|||
{ |
|||
public static readonly TheoryData<int> BoxBlurValues |
|||
= new TheoryData<int> |
|||
{ |
|||
3, |
|||
5 |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(BoxBlurValues), DefaultPixelType)] |
|||
public void ImageShouldApplyBoxBlurFilter<TPixel>(TestImageProvider<TPixel> provider, int value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Mutate(x => x.BoxBlur(value)); |
|||
image.DebugSave(provider, value); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(BoxBlurValues), DefaultPixelType)] |
|||
public void ImageShouldApplyBoxBlurFilterInBox<TPixel>(TestImageProvider<TPixel> provider, int value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (Image<TPixel> image = source.Clone()) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.Mutate(x => x.BoxBlur(value, bounds)); |
|||
image.DebugSave(provider, value); |
|||
protected override void Apply<TPixel>(IImageProcessingContext<TPixel> ctx, int value) => ctx.BoxBlur(value); |
|||
|
|||
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds); |
|||
} |
|||
} |
|||
protected override void Apply<TPixel>(IImageProcessingContext<TPixel> ctx, int value, Rectangle bounds) => |
|||
ctx.BoxBlur(value, bounds); |
|||
} |
|||
} |
|||
@ -1 +1 @@ |
|||
Subproject commit 1ca515499663e8b0b7c924a49b8d212f7447bdb0 |
|||
Subproject commit 2a3247c6da18b8a96cc71e1f2862ac03f2a42315 |
|||
Loading…
Reference in new issue