Browse Source

Add chroma as metric and swap from mathcal L to normal L for lightness

Kirk Trombley 3 years ago
parent
commit
593089b375
2 changed files with 16 additions and 6 deletions
  1. 10 2
      web/metrics.js
  2. 6 4
      web/render.js

+ 10 - 2
web/metrics.js

@@ -83,13 +83,21 @@ const metrics = {
     evaluate: data => data.inertia,
   },
   lightness: {
-    option: "Mean Lightness ()",
-    displayName: String.raw`\mathcal{L}`,
+    option: "Mean Lightness (L)",
+    displayName: "L",
     displayBody: (p, space) => String.raw`
       \text{comp}_{\vec{${space === "jab" ? "J" : "L"}}}{\vec{\mu}\left(${p}\right)}
     `,
     evaluate: data => data.mu.lightness,
   },
+  chroma: {
+    option: "Mean Chroma (C)",
+    displayName: "C",
+    displayBody: (p, space) => String.raw`
+      \text{chroma}\left(\vec{\mu}\left(${p}\right)\right)
+    `,
+    evaluate: data => data.mu.chroma,
+  },
   muNuAngle: {
     option: "Mu-Nu Angle (V)",
     displayName: "V",

+ 6 - 4
web/render.js

@@ -58,7 +58,8 @@ const renderPokemonTileCluster = (area, totalSize, { mu, nu }, scores) => {
             ["", nu[1].toFixed(2) + ","],
             ["", nu[2].toFixed(2) + ")"],
             ["I =", scores.inertia.toFixed(2)],
-            ["ℒ =", scores.lightness.toFixed(2)],
+            ["L =", scores.lightness.toFixed(2)],
+            ["C =", scores.chroma.toFixed(2)],
             ["V =", scores.muNuAngle.toFixed(2)],
             ["N =", scores.size],
           ]
@@ -125,12 +126,13 @@ const renderPokemonTile = (kind, name, { total: { mu, nu, size }, clusters }, sc
           <hr style="width: 80%; color: ${textColor}"/>
           ${ renderStatRow(
             [ ["μ =", `(${mu.vector.map(c => c.toFixed(2)).join(", ")})`, "vector"],
-              ["I =", scores.total.inertia.toFixed(2)],
-              ["ℒ =", scores.total.lightness.toFixed(2)],
+              ["ν =", `(${nu.map(c => c.toFixed(2)).join(", ")})`, "vector"],
             ].map(([lbl, val, cls]) => renderStatPair(lbl, val, cls))
           )}
           ${ renderStatRow(
-            [ ["ν =", `(${nu.map(c => c.toFixed(2)).join(", ")})`, "vector"],
+            [ ["I =", scores.total.inertia.toFixed(2)],
+              ["L =", scores.total.lightness.toFixed(2)],
+              ["C =", scores.total.chroma.toFixed(2)],
               ["V =", scores.total.muNuAngle.toFixed(2)],
               ["N =", size],
             ].map(([lbl, val, cls]) => renderStatPair(lbl, val, cls))