-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
444 additions
and
75 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
namespace Aardvark.OpenCV.Benchmarks | ||
|
||
open Aardvark.Base | ||
open Aardvark.OpenCV | ||
open BenchmarkDotNet.Attributes | ||
|
||
module ``Image Processing Benchmarks`` = | ||
|
||
type Scaling() = | ||
|
||
[<DefaultValue; Params(128, 1024, 2048, 4096)>] | ||
val mutable Size : int | ||
|
||
[<DefaultValue; Params(ImageInterpolation.Linear, ImageInterpolation.Cubic, ImageInterpolation.Lanczos)>] | ||
val mutable Interpolation : ImageInterpolation | ||
|
||
let mutable image = null | ||
|
||
let scaleFactor = V2d(0.234, 0.894) | ||
|
||
[<GlobalSetup>] | ||
member x.Setup() = | ||
Aardvark.Init() | ||
let rnd = RandomSystem 0 | ||
image <- new PixImage<float32>(Col.Format.RGBA, x.Size, x.Size) | ||
image.Volume.SetByIndex(ignore >> rnd.UniformFloat) |> ignore | ||
|
||
[<Benchmark(Description = "Aardvark (Tensors)", Baseline = true)>] | ||
member x.AardvarkTensors() = | ||
let volume = Aardvark.Base.TensorExtensions.Scaled(image.Volume, scaleFactor, x.Interpolation) | ||
PixImage<float32>(image.Format, volume) | ||
|
||
[<Benchmark>] | ||
member x.OpenCV() = | ||
ImageProcessing.ScaledOpenCV(image, scaleFactor, x.Interpolation) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,20 @@ | ||
namespace Aardvark.OpenCV.Benchmarks | ||
|
||
open System.Reflection | ||
open BenchmarkDotNet.Running; | ||
open BenchmarkDotNet.Configs | ||
open BenchmarkDotNet.Jobs | ||
open BenchmarkDotNet.Toolchains | ||
|
||
module Program = | ||
|
||
[<EntryPoint>] | ||
let main argv = | ||
|
||
let cfg = | ||
let job = Job.ShortRun.WithToolchain(InProcess.Emit.InProcessEmitToolchain.Instance) | ||
ManualConfig.Create(DefaultConfig.Instance).WithOptions(ConfigOptions.DisableOptimizationsValidator).AddJob(job) | ||
|
||
BenchmarkSwitcher.FromAssembly(Assembly.GetExecutingAssembly()).Run(argv, cfg) |> ignore | ||
|
||
0 |
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,38 @@ | ||
using Aardvark.Base; | ||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace Aardvark.OpenCV.Tests | ||
{ | ||
public class Scaling | ||
{ | ||
[Params(128, 1024, 2048, 4096)] | ||
public int Size; | ||
|
||
[Params(ImageInterpolation.Linear, ImageInterpolation.Cubic)] | ||
public ImageInterpolation Interpolation; | ||
|
||
private PixImage<float> _image; | ||
|
||
private readonly V2d _scaleFactor = new (0.234, 0.894); | ||
|
||
[GlobalSetup] | ||
public void Init() | ||
{ | ||
Aardvark.Base.Aardvark.Init(); | ||
var rnd = new RandomSystem(0); | ||
_image = new PixImage<float>(Col.Format.RGBA, new V2i(Size, Size)); | ||
_image.Volume.SetByIndex((_) => rnd.UniformFloat()); | ||
} | ||
|
||
[Benchmark(Description = "Aardvark (Tensors)", Baseline = true)] | ||
public PixImage<float> AardvarkTensors() | ||
{ | ||
var volume = Aardvark.Base.TensorExtensions.Scaled(_image.Volume, _scaleFactor, Interpolation); | ||
return new PixImage<float>(_image.Format, volume); | ||
} | ||
|
||
[Benchmark] | ||
public PixImage<float> OpenCV() | ||
=> TensorExtensions.ScaledOpenCV(_image, _scaleFactor, Interpolation); | ||
} | ||
} |
Oops, something went wrong.