Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
color / color-delta-e76OpenRuns on Liberas

Color difference CIE76

The CIE76 color difference ΔE*ab between CIE Lab colors a and b: √(dL × dL + da × da + db × db) with dL = b.l − a.l, da = b.a − a.a, db = b.b − a.b, summed left to right. Every present number must be finite with magnitude at most 1,000,000, else an error. Arithmetic is IEEE 754 binary64, each operation rounded to nearest-even, in the order written (no fused multiply-add). The square root is correctly rounded, so the binary64 result matches bit for bit.

From your terminal

terminal
npm i -g https://liberas.dev/cli/liberas.tgz
export LIBERAS_URL=https://liberas.dev
liberas init color-delta-e76 --lang rust
cd color-delta-e76 && liberas build && liberas submit

Save a token once with liberas login (make it on your page, /me, after signing in). init scaffolds the interface, the vectors and a stub in Rust (--lang js for light specs).

Interface (WIT)22 lines›
color-delta-e76.wit
package root:component;

world root {
  import liberas:color/types@0.1.0;

  export liberas:color/delta-e76@0.1.0;
}
package liberas:color@0.1.0 {
  interface types {
    record lab {
      l: f64,
      a: f64,
      b: f64,
    }
  }
  interface delta-e76 {
    use types.{lab};

    difference: func(a: lab, b: lab) -> result<f64, string>;
  }
}
Test vectors11›
color-delta-e76.cases.json
[
  {
    "args": {
      "a": {
        "a": 2.6772,
        "b": -79.7751,
        "l": 50
      },
      "b": {
        "a": 0,
        "b": -82.7485,
        "l": 50
      }
    }
  },
  {
    "args": {
      "a": {
        "a": 0,
        "b": 0,
        "l": 0
      },
      "b": {
        "a": 0,
        "b": 0,
        "l": 100
      }
    }
  },
  {
    "args": {
      "a": {
        "a": 80.0925,
        "b": 67.2032,
        "l": 53.2408
      },
      "b": {
        "a": 80.0925,
        "b": 67.2032,
        "l": 53.2408
      }
    }
  },
  {
    "args": {
      "a": {
        "a": -34.0099,
        "b": 36.2677,
        "l": 60.2574
      },
      "b": {
        "a": -34.1751,
        "b": 39.4387,
        "l": 60.4626
      }
    }
  },
  {
    "args": {
      "a": {
        "a": 3,
        "b": 4,
        "l": 0
      },
      "b": {
        "a": 0,
        "b": 0,
        "l": 0
      }
    }
  },
  {
    "args": {
      "a": {
        "a": -1000000,
        "b": 1000000,
        "l": 1000000
      },
      "b": {
        "a": 1000000,
        "b": -1000000,
        "l": -1000000
      }
    }
  },
  {
    "args": {
      "a": {
        "a": 0.2,
        "b": 0.3,
        "l": 0.1
      },
      "b": {
        "a": 0.2,
        "b": 0.1,
        "l": 0.3
      }
    }
  },
  {
    "args": {
      "a": {
        "a": 0,
        "b": 0,
        "l": 0
      },
      "b": {
        "a": 0,
        "b": 0,
        "l": 0
      }
    }
  },
  {
    "args": {
      "a": {
        "a": 0,
        "b": 0,
        "l": "NaN"
      },
      "b": {
        "a": 0,
        "b": 0,
        "l": 0
      }
    }
  },
  {
    "args": {
      "a": {
        "a": 0,
        "b": 0,
        "l": 0
      },
      "b": {
        "a": "Infinity",
        "b": 0,
        "l": 0
      }
    }
  },
  {
    "args": {
      "a": {
        "a": 0,
        "b": 0,
        "l": 1000001
      },
      "b": {
        "a": 0,
        "b": 0,
        "l": 0
      }
    }
  }
]
Verification6›
  • Outputs must match the private reference implementation bit for bit.
  • Cases are the spec's 11 vectors plus ones generated from the interface's types: edge values and random ones seeded by your component's hash.
  • Components may import nothing but specs: no files, no network, no clock.
  • Runs on Liberas: the component never leaves the platform, and every call is metered on the ledger.
  • A remote call may execute up to 1,000,000 instructions.
  • Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.