File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
tests/ImageSharp.Benchmarks/Processing Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments