A precomputed SSIMULACRA2 reference image for efficient batch comparison.
Build one with new/4 (optionally passing a format: — see Ssimulacra2
for the supported formats; default :rgb888), then call compare/2
repeatedly against candidate images of the same dimensions and format. This
reuses the reference's internal pyramid and is roughly twice as fast per
comparison as Ssimulacra2.compare/5 — ideal for a quality-search loop
comparing many encodings against one original.
Summary
Functions
Compare a candidate against the precomputed reference (same format as the reference).
Like compare/3 but returns the bare score or raises Ssimulacra2.Error.
Precompute a reference from a packed binary of the given format (default :rgb888).
Like new/4 but returns the reference or raises Ssimulacra2.Error.
Types
@type t() :: %Ssimulacra2.Reference{ format: atom(), height: pos_integer(), resource: reference(), width: pos_integer() }
Functions
@spec compare(t(), Ssimulacra2.image_data(), keyword()) :: {:ok, float()} | {:error, Ssimulacra2.reason()}
Compare a candidate against the precomputed reference (same format as the reference).
Accepts cancel: (an Ssimulacra2.CancelRef) and timeout:
(milliseconds) to abort an in-flight comparison; see Ssimulacra2.compare/5.
Returns {:error, :cancelled} or {:error, :timeout} respectively.
@spec compare!(t(), Ssimulacra2.image_data(), keyword()) :: float()
Like compare/3 but returns the bare score or raises Ssimulacra2.Error.
@spec new(Ssimulacra2.image_data(), pos_integer(), pos_integer(), keyword()) :: {:ok, t()} | {:error, Ssimulacra2.reason()}
Precompute a reference from a packed binary of the given format (default :rgb888).
@spec new!(Ssimulacra2.image_data(), pos_integer(), pos_integer(), keyword()) :: t()
Like new/4 but returns the reference or raises Ssimulacra2.Error.