A C# binding library for FLIP v1.7. Compatible with Unity.
dotnet add package FlipBinding.CSharp-
If you are using macOS and have a
ProjectSettings/Packages/com.github-glitchenzo.nugetforunity/NativeRuntimeSettings.jsonfile created with NuGetForUnity v4.5.0 or earlier, insert the following configuration entry into the file:{ "configurations": [ { "cpuArchitecture": "AnyCPU", "editorCpuArchitecture": "AnyCPU", "editorOperatingSystem": "OSX", "runtime": "osx", "supportedPlatformTargets": [ "StandaloneOSX" ] } ] } -
Open the NuGetForUnity window via NuGet > Manage NuGet Packages, search for "FlipBinding.CSharp", and click Install.
Important
When running on the Ubuntu 22.04 image (e.g., GameCI provided images), the GLIBCXX_3.4.32 (GCC 13+) required by FLIP's native libraries is missing. So, you will need to create a custom Docker image that includes libstdc++6 from GCC 13.
using FlipBinding.CSharp;
// Image data is in linear RGB interleaved format [r,g,b,r,g,b,...]
float[] reference = /* reference image */;
float[] test = /* test image */;
var result = Flip.Evaluate(reference, test, width, height);
// Mean error value (0-1, higher means greater difference)
Console.WriteLine($"Mean FLIP error: {result.MeanError}");
// Get per-pixel error value
float pixelError = result.GetPixel(x, y);For HDR image comparison, specify useHdr: true:
var result = Flip.Evaluate(reference, test, width, height,
useHdr: true, tonemapper, startExposure, stopExposure, numExposures);You can get the error map as an RGB color map for visualization:
var result = Flip.Evaluate(reference, test, width, height, applyMagmaMap: true);
// Get RGB values
var (r, g, b) = result.GetPixelRgb(x, y);public static FlipResult Evaluate(
float[] reference, // Reference image (linear RGB)
float[] test, // Test image (linear RGB)
int width, // Image width
int height, // Image height
bool useHdr = false, // Use HDR-FLIP if true
float ppd = 67.02f, // Pixels per degree. Default value based on: 0.7m viewing distance, 3840px resolution, 0.7m monitor width.
Tonemapper tonemapper = Tonemapper.Aces,
float startExposure = float.PositiveInfinity,
float stopExposure = float.PositiveInfinity,
int numExposures = -1,
bool applyMagmaMap = false // Apply Magma color map
)Note
- Image data must be in linear RGB. If using sRGB, convert beforehand
- Array size must be
width * height * 3(RGB interleaved format)
You can calculate PPD from viewing conditions:
float ppd = Flip.CalculatePpd(
viewingDistance: 0.5f, // Viewing distance (meters)
resolutionX: 2560, // Horizontal resolution (pixels)
monitorWidth: 0.6f // Monitor width (meters)
);
var result = Flip.Evaluate(reference, test, width, height, ppd: ppd);This library is licensed under the MIT License.
This library includes binary distributions of FLIP v1.7, which is licensed under the BSD 3-Clause License by NVIDIA CORPORATION & AFFILIATES. See THIRD-PARTY-NOTICES.txt for details.