Browse Source

rename chromalight metric, redo weighting, tweak weighting on alpha

Kirk Trombley 3 years ago
parent
commit
61527e2e0c
3 changed files with 10 additions and 9 deletions
  1. 1 1
      nearest.html
  2. 7 6
      web/metrics.js
  3. 2 2
      web/render.js

+ 1 - 1
nearest.html

@@ -22,7 +22,7 @@
       number: 10,
       number: 10,
       useCluster: true,
       useCluster: true,
       clusterSettings: {
       clusterSettings: {
-        sortMetric: "chromaLight",
+        sortMetric: "intensity",
         scaleOption: "direct",
         scaleOption: "direct",
         sortOrder: "max",
         sortOrder: "max",
       },
       },

+ 7 - 6
web/metrics.js

@@ -3,7 +3,7 @@ const metrics = {
     option: "Geometric Difference (α)",
     option: "Geometric Difference (α)",
     displayName: String.raw`\alpha`,
     displayName: String.raw`\alpha`,
     displayBody: p => String.raw`
     displayBody: p => String.raw`
-      \sqrt{\sigma\left(${p}\right)^{2 - L\left(\vec{q}\right)} \Theta\left(${p}\right)^{L\left(\vec{q}\right)}}
+      \sqrt{\sigma\left(${p}\right)^{2 - \sqrt{L\left(\vec{q}\right)}} \Theta\left(${p}\right)^{\sqrt{L\left(\vec{q}\right)}}}
     `,
     `,
     evaluate: () => 0, // calculated below
     evaluate: () => 0, // calculated below
   },
   },
@@ -108,11 +108,11 @@ const metrics = {
     displayBody: p => String.raw`\text{chroma}\left(\vec{\mu}\left(${p}\right)\right)`,
     displayBody: p => String.raw`\text{chroma}\left(\vec{\mu}\left(${p}\right)\right)`,
     evaluate: data => data.mu.chroma,
     evaluate: data => data.mu.chroma,
   },
   },
-  chromaLight: {
-    option: "Colorfulness (γ)",
+  intensity: {
+    option: "Visual Intensity (γ)",
     displayName: String.raw`\gamma`,
     displayName: String.raw`\gamma`,
-    displayBody: p => String.raw`\sqrt{C\left(${p}\right) L\left(${p}\right)}`,
-    evaluate: data => Math.sqrt(data.mu.lightness * data.mu.chroma),
+    displayBody: p => String.raw`\sqrt[3]{C\left(${p}\right) L\left(${p}\right)^2}`,
+    evaluate: data => Math.cbrt(data.mu.chroma * data.mu.lightness * data.mu.lightness)
   },
   },
 };
 };
 
 
@@ -122,6 +122,7 @@ const applyMetrics = (data, target) => {
       .map(([name, metric]) => [name, metric.evaluate(data, target)])
       .map(([name, metric]) => [name, metric.evaluate(data, target)])
   );
   );
   // rearranges to geometric mean of sigma and bigTheta
   // rearranges to geometric mean of sigma and bigTheta
-  scores.alpha = Math.sqrt(Math.pow(scores.sigma, 2 - target.lightness) * Math.pow(scores.bigTheta, target.lightness));
+  const power = Math.sqrt(target.lightness)
+  scores.alpha = Math.sqrt(Math.pow(scores.sigma, 2 - power) * Math.pow(scores.bigTheta, power));
   return scores;
   return scores;
 };
 };

+ 2 - 2
web/render.js

@@ -60,7 +60,7 @@ const renderPokemonTileCluster = (area, totalSize, { mu, nu }, scores) => {
             ["I =", scores.inertia.toFixed(2)],
             ["I =", scores.inertia.toFixed(2)],
             ["L =", scores.lightness.toFixed(2)],
             ["L =", scores.lightness.toFixed(2)],
             ["C =", scores.chroma.toFixed(2)],
             ["C =", scores.chroma.toFixed(2)],
-            ["γ = ", scores.chromaLight.toFixed(2)],
+            ["γ = ", scores.intensity.toFixed(2)],
             ["V =", scores.muNuAngle.toFixed(2)],
             ["V =", scores.muNuAngle.toFixed(2)],
             ["N =", scores.size],
             ["N =", scores.size],
           ]
           ]
@@ -139,7 +139,7 @@ const renderPokemonTile = (kind, name, { total: { mu, nu, size }, clusters }, sc
           ${ renderStatRow(
           ${ renderStatRow(
             [ ["L =", scores.total.lightness.toFixed(2)],
             [ ["L =", scores.total.lightness.toFixed(2)],
               ["C =", scores.total.chroma.toFixed(2)],
               ["C =", scores.total.chroma.toFixed(2)],
-              ["γ = ", scores.total.chromaLight.toFixed(2)],
+              ["γ = ", scores.total.intensity.toFixed(2)],
             ].map(([lbl, val, cls]) => renderStatPair(lbl, val, cls))
             ].map(([lbl, val, cls]) => renderStatPair(lbl, val, cls))
           )}
           )}
           ${ bestClusterIndex < 0 ? "" : `<hr style="width: 80%; color: ${textColor}"/>` }
           ${ bestClusterIndex < 0 ? "" : `<hr style="width: 80%; color: ${textColor}"/>` }