|
|
|
@ -14,31 +14,34 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters |
|
|
|
public class FilterTest : FileTestBase |
|
|
|
{ |
|
|
|
[Theory] |
|
|
|
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|
|
|
[WithTestPatternImages(100, 100, DefaultPixelType)] |
|
|
|
public void ImageShouldApplyFilter<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
using (Image<TPixel> image = provider.GetImage()) |
|
|
|
{ |
|
|
|
Matrix4x4 brightness = MatrixFilters.CreateBrightnessFilter(0.9F); |
|
|
|
Matrix4x4 contrast = MatrixFilters.CreateContrastFilter(1.2F); |
|
|
|
Matrix4x4 hue = MatrixFilters.CreateHueFilter(180F); |
|
|
|
Matrix4x4 saturation = MatrixFilters.CreateSaturateFilter(1.5F); |
|
|
|
image.Mutate(x => x.Filter(brightness * contrast * saturation)); |
|
|
|
image.Mutate(x => x.Filter(brightness * hue * saturation)); |
|
|
|
image.DebugSave(provider); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|
|
|
[WithTestPatternImages(100, 100, DefaultPixelType)] |
|
|
|
public void ImageShouldApplyFilterInBox<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
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); |
|
|
|
var bounds = new Rectangle(image.Width / 4, image.Width / 4, image.Width / 2, image.Height / 2); |
|
|
|
|
|
|
|
image.Mutate(x => x.Filter(MatrixFilters.CreateBrightnessFilter(1.2F) * MatrixFilters.CreateContrastFilter(1.2F), bounds)); |
|
|
|
Matrix4x4 brightness = MatrixFilters.CreateBrightnessFilter(0.9F); |
|
|
|
Matrix4x4 hue = MatrixFilters.CreateHueFilter(180F); |
|
|
|
Matrix4x4 saturation = MatrixFilters.CreateSaturateFilter(1.5F); |
|
|
|
image.Mutate(x => x.Filter(brightness * hue * saturation, bounds)); |
|
|
|
image.DebugSave(provider); |
|
|
|
|
|
|
|
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds); |