-
-
Notifications
You must be signed in to change notification settings - Fork 855
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1431 from SixLabors/bp/fix1429
Use GetPixelRowSpan to access pixel data in Histogram equalization
- Loading branch information
Showing
3 changed files
with
83 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
tests/ImageSharp.Benchmarks/Processing/HistogramEqualization.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) Six Labors. | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
using System.IO; | ||
using BenchmarkDotNet.Attributes; | ||
using SixLabors.ImageSharp.PixelFormats; | ||
using SixLabors.ImageSharp.Processing; | ||
using SixLabors.ImageSharp.Processing.Processors.Normalization; | ||
using SixLabors.ImageSharp.Tests; | ||
|
||
namespace SixLabors.ImageSharp.Benchmarks.Processing | ||
{ | ||
[Config(typeof(Config.ShortClr))] | ||
public class HistogramEqualization : BenchmarkBase | ||
{ | ||
private Image<Rgba32> image; | ||
|
||
[GlobalSetup] | ||
public void ReadImages() | ||
{ | ||
if (this.image == null) | ||
{ | ||
this.image = Image.Load<Rgba32>(File.OpenRead(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, TestImages.Jpeg.Baseline.HistogramEqImage))); | ||
} | ||
} | ||
|
||
[GlobalCleanup] | ||
public void Cleanup() | ||
{ | ||
this.image.Dispose(); | ||
} | ||
|
||
[Benchmark(Description = "Global Histogram Equalization")] | ||
public void GlobalHistogramEqualization() | ||
{ | ||
this.image.Mutate(img => img.HistogramEqualization(new HistogramEqualizationOptions() | ||
{ | ||
LuminanceLevels = 256, | ||
Method = HistogramEqualizationMethod.Global | ||
})); | ||
} | ||
|
||
[Benchmark(Description = "AdaptiveHistogramEqualization (Tile interpolation)")] | ||
public void AdaptiveHistogramEqualization() | ||
{ | ||
this.image.Mutate(img => img.HistogramEqualization(new HistogramEqualizationOptions() | ||
{ | ||
LuminanceLevels = 256, | ||
Method = HistogramEqualizationMethod.AdaptiveTileInterpolation | ||
})); | ||
} | ||
} | ||
} |