Ssimulacra2.Vix (Ssimulacra2 v0.1.0)

Copy Markdown View Source

Convenience wrappers that accept Vix.Vips.Image structs.

Only compiled when the optional :vix dependency is available. 8-bit sources are coerced to 8-bit sRGB (:rgb888); higher-bit-depth sources are preserved as 16-bit sRGB (:rgb16). Alpha is flattened in both cases.

Summary

Functions

Compare a Vix candidate against a reference.

Build a Ssimulacra2.Reference from a Vix image, preserving bit depth.

Functions

compare(reference, distorted)

@spec compare(Vix.Vips.Image.t(), Vix.Vips.Image.t()) ::
  {:ok, float()} | {:error, term()}
@spec compare(Ssimulacra2.Reference.t(), Vix.Vips.Image.t()) ::
  {:ok, float()} | {:error, term()}

Compare a Vix candidate against a reference.

Given two Image.t()s, the reference pyramid is rebuilt every call. Given a precomputed Ssimulacra2.Reference as the first argument, it is reused against the candidate — coerce the candidate to the reference's format and compare. Use the precompute form when comparing many candidates against one original.

reference(image)

@spec reference(Vix.Vips.Image.t()) ::
  {:ok, Ssimulacra2.Reference.t()} | {:error, term()}

Build a Ssimulacra2.Reference from a Vix image, preserving bit depth.