Skip to content

gamut-icc: decide whether gray_with_gamma should bound gamma colorimetrically rather than by the s15Fixed16 encoding #589

Description

@justin13888

After PR #542, IccProfile::gray_with_gamma accepts a gamma in

0.5 / 65536 = 7.62939453125e-6  ..<  (2^31 - 0.5) / 65536 = 32767.99999237060546875

and declines everything else. That bound is the encoding's: below it the parametricCurveType type 0 parameter rounds to raw 0 (a curve that maps every input to white) and at or above it the parameter saturates to a gamma the caller did not ask for. Inside the bound the encoding is a rounding of at most half a quantum, and the constructor writes what it was given.

What the bound is not is a statement that the gamma is useful. gray_with_gamma(1e-5) and gray_with_gamma(30000.0) both succeed and both produce a profile whose tone curve is, to any practical precision, a step at one end of the range. Real grey profiles carry roughly 1.0 ..= 3.0; the historical extremes are ~1.8 (Apple) and ~2.8 (BT.470-6 System B, G).

The question

Should the constructor refuse a colorimetrically meaningless gamma, and if so on what authority? ICC.1:2022 states no range for the type 0 parameter — a s15Fixed16 is the whole of what the format says — so any narrower bound is this crate's policy, not conformance. Options:

  1. Keep the encoding bound (status quo). The constructor is a faithful encoder; judging the caller's colorimetry is not its job. Costs nothing and never refuses a legitimate profile.
  2. Add a documented sanity range such as (0.0, 100.0], refusing outside it. Catches a units mistake (a caller passing 2.2e-5 or a raw s15Fixed16), at the cost of a policy the spec does not sanction and a breaking change to a shipped constructor.
  3. Split the two: keep the wide constructor and add a checked one, or return a diagnostic alongside the profile.

Whichever way it goes, the answer belongs in the doc comment as a stated policy rather than being left as a side effect of the fixed-point format. Deciding it needs evidence about who calls this and what they pass, which #542 does not have.

Refs #424, #542.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions