Skip to content

Commit

Permalink
Implement scaling (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyazinthh committed Sep 10, 2024
1 parent b0230f2 commit 45151c1
Show file tree
Hide file tree
Showing 15 changed files with 444 additions and 75 deletions.
11 changes: 8 additions & 3 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ group Test
storage: none
source https://api.nuget.org/v3/index.json

nuget NUnit ~> 3.14.0
nuget NUnit3TestAdapter ~> 4.5.0
nuget Microsoft.NET.Test.Sdk ~> 17.9.0
nuget FSharp.Core ~> 8.0.0

nuget FsUnit ~> 6.0.0
nuget NUnit ~> 4.2.2
nuget NUnit3TestAdapter ~> 4.6.0
nuget Microsoft.NET.Test.Sdk ~> 17.9.0

nuget BenchmarkDotNet ~> 0.14.0
136 changes: 120 additions & 16 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@ STORAGE: NONE
RESTRICTION: || (== net8.0) (== netstandard2.0)
NUGET
remote: https://api.nuget.org/v3/index.json
Aardvark.Base (5.3)
Aardvark.Base.Telemetry (5.3)
Aardvark.Base (5.3.3)
Aardvark.Base.Telemetry (5.3.3)
SingleFileExtractor.Core (>= 2.2.1 < 2.3)
System.Collections.Immutable (>= 8.0)
System.Reflection.Metadata (>= 8.0)
System.Text.Json (>= 8.0.4)
Aardvark.Base.FSharp (5.3)
Aardvark.Base (5.3)
Aardvark.Base.FSharp (5.3.3)
Aardvark.Base (5.3.3)
Aardvark.Base.TypeProviders (>= 4.5.15 < 4.6)
FSharp.Core (>= 8.0)
FSharp.Data.Adaptive (>= 1.2 < 1.3)
FsPickler (>= 5.3.2 < 5.4)
System.Dynamic.Runtime (>= 4.3 < 4.4)
Aardvark.Base.Telemetry (5.3)
Aardvark.Base.Tensors (5.3)
Aardvark.Base (5.3)
Aardvark.Base.FSharp (5.3)
Aardvark.Base.Telemetry (5.3.3)
Aardvark.Base.Tensors (5.3.3)
Aardvark.Base (5.3.3)
Aardvark.Base.FSharp (5.3.3)
FSharp.Core (>= 8.0)
Aardvark.Base.TypeProviders (4.5.15)
FSharp.Core (>= 4.2.3)
Expand All @@ -36,6 +37,8 @@ NUGET
OpenCvSharp4 (4.10.0.20240616)
System.Memory (>= 4.5.5)
System.Runtime.CompilerServices.Unsafe (>= 6.0)
SingleFileExtractor.Core (2.2.1)
System.Memory (>= 4.5.5) - restriction: || (&& (== net8.0) (< netstandard2.1)) (== netstandard2.0)
System.Buffers (4.5.1) - restriction: || (&& (== net8.0) (>= monotouch)) (&& (== net8.0) (>= net461)) (&& (== net8.0) (< netcoreapp2.0)) (&& (== net8.0) (< netstandard1.1)) (&& (== net8.0) (< netstandard2.0)) (&& (== net8.0) (>= xamarinios)) (&& (== net8.0) (>= xamarinmac)) (&& (== net8.0) (>= xamarintvos)) (&& (== net8.0) (>= xamarinwatchos)) (== netstandard2.0)
System.Collections (4.3)
Microsoft.NETCore.Platforms (>= 1.1)
Expand Down Expand Up @@ -176,22 +179,123 @@ STORAGE: NONE
RESTRICTION: || (== net8.0) (== netstandard2.0)
NUGET
remote: https://api.nuget.org/v3/index.json
BenchmarkDotNet (0.14)
BenchmarkDotNet.Annotations (>= 0.14)
CommandLineParser (>= 2.9.1)
Gee.External.Capstone (>= 2.3)
Iced (>= 1.17)
Microsoft.CodeAnalysis.CSharp (>= 4.1)
Microsoft.Diagnostics.Runtime (>= 2.2.332302)
Microsoft.Diagnostics.Tracing.TraceEvent (>= 3.1.8)
Microsoft.DotNet.PlatformAbstractions (>= 3.1.6)
Microsoft.Win32.Registry (>= 5.0) - restriction: || (&& (== net8.0) (< net6.0)) (== netstandard2.0)
Perfolizer (0.3.17)
System.Management (>= 5.0)
System.Numerics.Vectors (>= 4.5) - restriction: || (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Reflection.Emit (>= 4.7) - restriction: || (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Reflection.Emit.Lightweight (>= 4.7) - restriction: || (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (&& (== net8.0) (< net6.0)) (== netstandard2.0)
BenchmarkDotNet.Annotations (0.14)
CommandLineParser (2.9.1)
FSharp.Core (8.0.400)
FsUnit (6.0)
FSharp.Core (>= 5.0.2)
NUnit (>= 4.0.1)
Gee.External.Capstone (2.3)
Iced (1.21)
Microsoft.Bcl.AsyncInterfaces (8.0) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< net6.0)) (&& (== net8.0) (< netstandard2.1)) (== netstandard2.0)
System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< netstandard2.1)) (== netstandard2.0)
Microsoft.CodeAnalysis.Analyzers (3.3.4)
Microsoft.CodeAnalysis.Common (4.11)
Microsoft.CodeAnalysis.Analyzers (>= 3.3.4)
System.Buffers (>= 4.5.1) - restriction: || (&& (== net8.0) (< net7.0)) (== netstandard2.0)
System.Collections.Immutable (>= 8.0)
System.Memory (>= 4.5.5) - restriction: || (&& (== net8.0) (< net7.0)) (== netstandard2.0)
System.Numerics.Vectors (>= 4.5) - restriction: || (&& (== net8.0) (< net7.0)) (== netstandard2.0)
System.Reflection.Metadata (>= 8.0)
System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: || (&& (== net8.0) (< net7.0)) (== netstandard2.0)
System.Text.Encoding.CodePages (>= 7.0) - restriction: || (&& (== net8.0) (< net7.0)) (== netstandard2.0)
System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (&& (== net8.0) (< net7.0)) (== netstandard2.0)
Microsoft.CodeAnalysis.CSharp (4.11)
Microsoft.CodeAnalysis.Analyzers (>= 3.3.4)
Microsoft.CodeAnalysis.Common (4.11)
System.Buffers (>= 4.5.1) - restriction: || (&& (== net8.0) (< net7.0)) (== netstandard2.0)
System.Collections.Immutable (>= 8.0)
System.Memory (>= 4.5.5) - restriction: || (&& (== net8.0) (< net7.0)) (== netstandard2.0)
System.Numerics.Vectors (>= 4.5) - restriction: || (&& (== net8.0) (< net7.0)) (== netstandard2.0)
System.Reflection.Metadata (>= 8.0)
System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: || (&& (== net8.0) (< net7.0)) (== netstandard2.0)
System.Text.Encoding.CodePages (>= 7.0) - restriction: || (&& (== net8.0) (< net7.0)) (== netstandard2.0)
System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (&& (== net8.0) (< net7.0)) (== netstandard2.0)
Microsoft.CodeCoverage (17.10) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= net462)) (&& (== netstandard2.0) (>= netcoreapp3.1))
Microsoft.Diagnostics.NETCore.Client (0.2.532401)
Microsoft.Bcl.AsyncInterfaces (>= 6.0) - restriction: || (&& (== net8.0) (< net6.0)) (== netstandard2.0)
Microsoft.Extensions.Logging.Abstractions (>= 6.0.4)
System.Buffers (>= 4.5.1) - restriction: || (&& (== net8.0) (< net6.0)) (== netstandard2.0)
Microsoft.Diagnostics.Runtime (3.1.512801)
Microsoft.Diagnostics.NETCore.Client (>= 0.2.410101)
System.Collections.Immutable (>= 6.0) - restriction: || (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: || (&& (== net8.0) (< net6.0)) (== netstandard2.0)
Microsoft.Diagnostics.Tracing.TraceEvent (3.1.15)
Microsoft.Diagnostics.NETCore.Client (>= 0.2.510501)
Microsoft.Win32.Registry (>= 5.0)
System.Collections.Immutable (>= 8.0)
System.Reflection.Metadata (>= 8.0)
System.Reflection.TypeExtensions (>= 4.7)
System.Runtime.CompilerServices.Unsafe (>= 6.0)
Microsoft.DotNet.PlatformAbstractions (3.1.6)
Microsoft.Extensions.DependencyInjection.Abstractions (8.0.1)
Microsoft.Bcl.AsyncInterfaces (>= 8.0) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< netstandard2.1)) (== netstandard2.0)
System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< netstandard2.1)) (== netstandard2.0)
Microsoft.Extensions.Logging.Abstractions (8.0.1)
Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
System.Buffers (>= 4.5.1) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Memory (>= 4.5.5) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< net6.0)) (== netstandard2.0)
Microsoft.NET.Test.Sdk (17.9)
Microsoft.CodeCoverage (>= 17.9) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= net462)) (&& (== netstandard2.0) (>= netcoreapp3.1))
Microsoft.TestPlatform.TestHost (>= 17.9) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= netcoreapp3.1))
Microsoft.NETCore.Platforms (7.0.4)
Microsoft.TestPlatform.ObjectModel (17.10) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= netcoreapp3.1))
System.Reflection.Metadata (>= 1.6)
Microsoft.TestPlatform.TestHost (17.10) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= netcoreapp3.1))
Microsoft.TestPlatform.ObjectModel (>= 17.10) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= netcoreapp3.1))
Newtonsoft.Json (>= 13.0.1) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= netcoreapp3.1))
NETStandard.Library (2.0.3)
Microsoft.NETCore.Platforms (>= 1.1)
Microsoft.Win32.Registry (5.0)
System.Buffers (>= 4.5.1) - restriction: || (&& (== net8.0) (>= monoandroid) (< netstandard1.3)) (&& (== net8.0) (>= monotouch)) (&& (== net8.0) (< netcoreapp2.0)) (&& (== net8.0) (>= xamarinios)) (&& (== net8.0) (>= xamarinmac)) (&& (== net8.0) (>= xamarintvos)) (&& (== net8.0) (>= xamarinwatchos)) (== netstandard2.0)
System.Memory (>= 4.5.4) - restriction: || (&& (== net8.0) (< netcoreapp2.0)) (&& (== net8.0) (< netcoreapp2.1)) (&& (== net8.0) (>= uap10.1)) (== netstandard2.0)
System.Security.AccessControl (>= 5.0)
System.Security.Principal.Windows (>= 5.0)
Newtonsoft.Json (13.0.3) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= netcoreapp3.1))
NUnit (3.14)
NETStandard.Library (>= 2.0)
NUnit3TestAdapter (4.5)
System.Collections.Immutable (8.0) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= netcoreapp3.1))
System.Reflection.Metadata (8.0) - restriction: || (== net8.0) (&& (== netstandard2.0) (>= netcoreapp3.1))
NUnit (4.2.2)
NUnit3TestAdapter (4.6)
Perfolizer (0.3.17)
System.Memory (>= 4.5.5) - restriction: || (&& (== net8.0) (< netstandard2.1)) (== netstandard2.0)
System.Buffers (4.5.1) - restriction: || (&& (== net8.0) (>= monoandroid) (< netstandard1.3)) (&& (== net8.0) (>= monotouch)) (&& (== net8.0) (< net6.0) (>= xamarinios)) (&& (== net8.0) (< net6.0) (>= xamarinmac)) (&& (== net8.0) (< net6.0) (>= xamarintvos)) (&& (== net8.0) (< net6.0) (>= xamarinwatchos)) (&& (== net8.0) (< netcoreapp2.0)) (== netstandard2.0)
System.CodeDom (8.0)
System.Collections.Immutable (8.0)
System.Memory (>= 4.5.5) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< net6.0)) (&& (== net8.0) (< net7.0)) (== netstandard2.0)
System.Management (8.0)
System.CodeDom (>= 8.0)
System.Memory (4.5.5) - restriction: || (&& (== net8.0) (< netstandard2.1)) (== netstandard2.0)
System.Buffers (>= 4.5.1) - restriction: || (&& (== net8.0) (>= monotouch)) (&& (== net8.0) (>= net461)) (&& (== net8.0) (< netcoreapp2.0)) (&& (== net8.0) (< netstandard1.1)) (&& (== net8.0) (< netstandard2.0)) (&& (== net8.0) (>= xamarinios)) (&& (== net8.0) (>= xamarinmac)) (&& (== net8.0) (>= xamarintvos)) (&& (== net8.0) (>= xamarinwatchos)) (== netstandard2.0)
System.Numerics.Vectors (>= 4.4) - restriction: || (&& (== net8.0) (< netcoreapp2.0)) (== netstandard2.0)
System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (== net8.0) (>= monotouch)) (&& (== net8.0) (>= net461)) (&& (== net8.0) (< netcoreapp2.0)) (&& (== net8.0) (< netcoreapp2.1)) (&& (== net8.0) (< netstandard1.1)) (&& (== net8.0) (< netstandard2.0)) (&& (== net8.0) (>= uap10.1)) (&& (== net8.0) (>= xamarinios)) (&& (== net8.0) (>= xamarinmac)) (&& (== net8.0) (>= xamarintvos)) (&& (== net8.0) (>= xamarinwatchos)) (== netstandard2.0)
System.Numerics.Vectors (4.5) - restriction: || (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Reflection.Emit (4.7) - restriction: || (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Reflection.Emit.ILGeneration (>= 4.7) - restriction: || (&& (== net8.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net8.0) (< netstandard1.1)) (&& (== net8.0) (< netstandard2.0)) (&& (== net8.0) (>= uap10.1)) (== netstandard2.0)
System.Reflection.Emit.ILGeneration (4.7) - restriction: || (&& (== net8.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net8.0) (< netstandard1.1)) (&& (== net8.0) (< netstandard2.0)) (&& (== net8.0) (>= uap10.1)) (== netstandard2.0)
System.Reflection.Emit.Lightweight (4.7) - restriction: || (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Reflection.Emit.ILGeneration (>= 4.7) - restriction: || (&& (== net8.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net8.0) (< netstandard2.0)) (&& (== net8.0) (< portable-net45+wp8)) (&& (== net8.0) (>= uap10.1)) (== netstandard2.0)
System.Reflection.Metadata (8.0)
System.Collections.Immutable (>= 8.0)
System.Memory (>= 4.5.5) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Reflection.TypeExtensions (4.7)
System.Runtime.CompilerServices.Unsafe (6.0)
System.Security.AccessControl (6.0.1) - restriction: || (&& (== net8.0) (>= monoandroid) (< netstandard1.3)) (&& (== net8.0) (>= monotouch)) (&& (== net8.0) (>= net461)) (&& (== net8.0) (< net6.0)) (&& (== net8.0) (< netcoreapp2.0)) (&& (== net8.0) (>= uap10.1)) (== netstandard2.0)
System.Security.Principal.Windows (>= 5.0) - restriction: || (&& (== net8.0) (>= net461)) (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Security.Principal.Windows (5.0) - restriction: || (&& (== net8.0) (>= monoandroid) (< netstandard1.3)) (&& (== net8.0) (>= monotouch)) (&& (== net8.0) (>= net461)) (&& (== net8.0) (< net6.0)) (&& (== net8.0) (< netcoreapp2.0)) (&& (== net8.0) (>= uap10.1)) (== netstandard2.0)
System.Text.Encoding.CodePages (8.0) - restriction: || (&& (== net8.0) (< net7.0)) (== netstandard2.0)
System.Memory (>= 4.5.5) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: || (&& (== net8.0) (>= net462)) (&& (== net8.0) (< net6.0)) (&& (== net8.0) (< net7.0)) (== netstandard2.0)
System.Threading.Tasks.Extensions (4.5.4) - restriction: || (&& (== net8.0) (< net6.0)) (== netstandard2.0)
System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (== net8.0) (>= net461)) (&& (== net8.0) (< netcoreapp2.1)) (&& (== net8.0) (< netstandard1.0)) (&& (== net8.0) (< netstandard2.0)) (&& (== net8.0) (>= wp8)) (== netstandard2.0)
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>..\..\bin\Debug</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<OutputPath>..\..\bin\Release</OutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="Benchmarks\ImageBench.fs" />
<Compile Include="Tests\ClusteringTests.fs" />
<Compile Include="Tests\FittingTests.fs" />
<Compile Include="Tests\ImageTests.fs" />
<Compile Include="Program.fs" />
<None Include="paket.references" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Aardvark.OpenCV\Aardvark.OpenCV.csproj" />
</ItemGroup>
Expand Down
35 changes: 35 additions & 0 deletions src/Aardvark.OpenCV.Tests/Benchmarks/ImageBench.fs
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)
25 changes: 0 additions & 25 deletions src/Aardvark.OpenCV.Tests/ClusteringTests.cs

This file was deleted.

25 changes: 0 additions & 25 deletions src/Aardvark.OpenCV.Tests/FittingTests.cs

This file was deleted.

20 changes: 20 additions & 0 deletions src/Aardvark.OpenCV.Tests/Program.fs
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
38 changes: 38 additions & 0 deletions src/Aardvark.OpenCV.Tests/TensorExtensionsBench.cs
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);
}
}
Loading

0 comments on commit 45151c1

Please sign in to comment.