|
|
|
@ -6,6 +6,7 @@ using CommandLine; |
|
|
|
using CommandLine.Text; |
|
|
|
using SixLabors.ImageSharp.PixelFormats; |
|
|
|
using SixLabors.ImageSharp.Processing; |
|
|
|
using SixLabors.ImageSharp.Processing.Processors.Convolution; |
|
|
|
|
|
|
|
namespace SixLabors.ImageSharp.Tests.ProfilingSandbox; |
|
|
|
|
|
|
|
@ -49,10 +50,12 @@ public sealed class ProcessorThroughputBenchmark |
|
|
|
{ |
|
|
|
Method.Crop => this.Crop, |
|
|
|
Method.Edges => this.DetectEdges, |
|
|
|
Method.EdgesCompass => this.EdgesCompass, |
|
|
|
Method.DrawImage => this.DrawImage, |
|
|
|
Method.BinaryThreshold => this.BinaryThreshold, |
|
|
|
Method.Histogram => this.Histogram, |
|
|
|
Method.OilPaint => this.OilPaint, |
|
|
|
Method.GaussianBlur => this.GaussianBlur, |
|
|
|
_ => throw new NotImplementedException(), |
|
|
|
}; |
|
|
|
|
|
|
|
@ -138,6 +141,13 @@ public sealed class ProcessorThroughputBenchmark |
|
|
|
return image.Width * image.Height; |
|
|
|
} |
|
|
|
|
|
|
|
private int EdgesCompass() |
|
|
|
{ |
|
|
|
using Image<Rgba32> image = new(this.options.Width, this.options.Height); |
|
|
|
image.Mutate(this.configuration, x => x.DetectEdges(EdgeDetectorCompassKernel.Kirsch)); |
|
|
|
return image.Width * image.Height; |
|
|
|
} |
|
|
|
|
|
|
|
private int Crop() |
|
|
|
{ |
|
|
|
using Image<Rgba32> image = new(this.options.Width, this.options.Height); |
|
|
|
@ -151,32 +161,41 @@ public sealed class ProcessorThroughputBenchmark |
|
|
|
{ |
|
|
|
using Image<Rgba32> image = new(this.options.Width, this.options.Height); |
|
|
|
using Image<Rgba32> foreground = new(this.options.Width, this.options.Height); |
|
|
|
image.Mutate(c => c.DrawImage(foreground, 0.5f)); |
|
|
|
image.Mutate(this.configuration, c => c.DrawImage(foreground, 0.5f)); |
|
|
|
return image.Width * image.Height; |
|
|
|
} |
|
|
|
|
|
|
|
private int BinaryThreshold() |
|
|
|
{ |
|
|
|
using Image<Rgba32> image = new(this.options.Width, this.options.Height); |
|
|
|
image.Mutate(c => c.BinaryThreshold(0.5f)); |
|
|
|
image.Mutate(this.configuration, c => c.BinaryThreshold(0.5f)); |
|
|
|
return image.Width * image.Height; |
|
|
|
} |
|
|
|
|
|
|
|
private int Histogram() |
|
|
|
{ |
|
|
|
using Image<Rgba32> image = new(this.options.Width, this.options.Height); |
|
|
|
image.Mutate(c => c.HistogramEqualization()); |
|
|
|
image.Mutate(this.configuration, c => c.HistogramEqualization()); |
|
|
|
return image.Width * image.Height; |
|
|
|
} |
|
|
|
|
|
|
|
private int GaussianBlur() |
|
|
|
{ |
|
|
|
using Image<Rgba32> image = new(this.options.Width, this.options.Height); |
|
|
|
image.Mutate(this.configuration, c => c.GaussianBlur()); |
|
|
|
return image.Width * image.Height; |
|
|
|
} |
|
|
|
|
|
|
|
private enum Method |
|
|
|
{ |
|
|
|
Edges, |
|
|
|
EdgesCompass, |
|
|
|
Crop, |
|
|
|
DrawImage, |
|
|
|
BinaryThreshold, |
|
|
|
Histogram, |
|
|
|
OilPaint |
|
|
|
OilPaint, |
|
|
|
GaussianBlur, |
|
|
|
} |
|
|
|
|
|
|
|
private sealed class CommandLineOptions |
|
|
|
|