Skip to content

Commit 9bed14f

Browse files
committed
Add histogram equalization benchmark
1 parent 6b106da commit 9bed14f

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Apache License, Version 2.0.
3+
4+
using System.IO;
5+
using BenchmarkDotNet.Attributes;
6+
using SixLabors.ImageSharp.PixelFormats;
7+
using SixLabors.ImageSharp.Processing;
8+
using SixLabors.ImageSharp.Processing.Processors.Normalization;
9+
using SixLabors.ImageSharp.Tests;
10+
11+
namespace SixLabors.ImageSharp.Benchmarks.Processing
12+
{
13+
[Config(typeof(Config.ShortClr))]
14+
public class HistogramEqualization : BenchmarkBase
15+
{
16+
private Image<Rgba32> image;
17+
18+
[GlobalSetup]
19+
public void ReadImages()
20+
{
21+
if (this.image == null)
22+
{
23+
this.image = Image.Load<Rgba32>(File.OpenRead(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, TestImages.Jpeg.Baseline.HistogramEqImage)));
24+
}
25+
}
26+
27+
[GlobalCleanup]
28+
public void Cleanup()
29+
{
30+
this.image.Dispose();
31+
}
32+
33+
[Benchmark(Description = "Global Histogram Equalization")]
34+
public void GlobalHistogramEqualization()
35+
{
36+
this.image.Mutate(img => img.HistogramEqualization(new HistogramEqualizationOptions()
37+
{
38+
LuminanceLevels = 256,
39+
Method = HistogramEqualizationMethod.Global
40+
}));
41+
}
42+
43+
[Benchmark(Description = "AdaptiveHistogramEqualization (Tile interpolation)")]
44+
public void AdaptiveHistogramEqualization()
45+
{
46+
this.image.Mutate(img => img.HistogramEqualization(new HistogramEqualizationOptions()
47+
{
48+
LuminanceLevels = 256,
49+
Method = HistogramEqualizationMethod.AdaptiveTileInterpolation
50+
}));
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)