|
|
|
@ -6,10 +6,10 @@ |
|
|
|
namespace ImageSharp.Tests |
|
|
|
{ |
|
|
|
using System.IO; |
|
|
|
|
|
|
|
using ImageSharp.PixelFormats; |
|
|
|
using Xunit; |
|
|
|
|
|
|
|
public class GaussianBlurTest : FileTestBase |
|
|
|
public class GaussianBlurTest |
|
|
|
{ |
|
|
|
public static readonly TheoryData<int> GaussianBlurValues |
|
|
|
= new TheoryData<int> |
|
|
|
@ -19,19 +19,33 @@ namespace ImageSharp.Tests |
|
|
|
}; |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[MemberData(nameof(GaussianBlurValues))] |
|
|
|
public void ImageShouldApplyGaussianBlurFilter(int value) |
|
|
|
[WithTestPatternImages(nameof(GaussianBlurValues), 320, 240, PixelTypes.StandardImageClass)] |
|
|
|
public void ImageShouldApplyGaussianBlurFilter<TPixel>(TestImageProvider<TPixel> provider, int value) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
string path = this.CreateOutputDirectory("GaussianBlur"); |
|
|
|
using (Image<TPixel> image = provider.GetImage()) |
|
|
|
{ |
|
|
|
image.GaussianBlur(value) |
|
|
|
.DebugSave(provider); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
foreach (TestFile file in Files) |
|
|
|
[Theory] |
|
|
|
[WithTestPatternImages(nameof(GaussianBlurValues), 320, 240, PixelTypes.StandardImageClass)] |
|
|
|
public void ImageShouldApplyGaussianBlurFilterInBox<TPixel>(TestImageProvider<TPixel> provider, int value) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
using (Image<TPixel> source = provider.GetImage()) |
|
|
|
using (Image<TPixel> image = new Image<TPixel>(source)) |
|
|
|
{ |
|
|
|
string filename = file.GetFileName(value); |
|
|
|
using (Image image = file.CreateImage()) |
|
|
|
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|
|
|
{ |
|
|
|
image.GaussianBlur(value).Save(output); |
|
|
|
} |
|
|
|
Rectangle rect = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2); |
|
|
|
image.GaussianBlur(value, rect) |
|
|
|
.DebugSave(provider); |
|
|
|
|
|
|
|
// lets draw identical shapes over the blured areas and ensure that it didn't change the outer area
|
|
|
|
image.Fill(NamedColors<TPixel>.HotPink, rect); |
|
|
|
source.Fill(NamedColors<TPixel>.HotPink, rect); |
|
|
|
ImageComparer.CheckSimilarity(image, source); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|