Jelajahi Sumber

rename geo diff to arc diff and tweak units/cluster free calc

Kirk Trombley 2 tahun lalu
induk
melakukan
fa25248ab5
2 mengubah file dengan 8 tambahan dan 6 penghapusan
  1. 2 2
      web/index.html
  2. 6 4
      web/main.js

+ 2 - 2
web/index.html

@@ -32,7 +32,7 @@
           </label>
         </div>
         <select class="pill-shape highlight-border" name="compare" disabled>
-          <option value="geoDiff">Geometric Difference (Ω)</option>
+          <option value="arcDiff">Arc Difference (Ω)</option>
           <option value="psi">RMS Deviation (Ψ)</option>
           <option value="theta">Mean Cosine Difference (Θ)</option>
           <option value="psiL">RMS Deviation Lightness (Lᵣₘₛ)</option>
@@ -63,7 +63,7 @@
     </template>
 
     <template id="pkmn-data-template">
-      <div>Ω&nbsp;=&nbsp;<span bind-to="geoDiff"></span></div>
+      <div>Ω&nbsp;=&nbsp;<span bind-to="arcDiff"></span></div>
       <div>|Ψ|&nbsp;=&nbsp;<span bind-to="psi"></span></div>
       <div>Θ&nbsp;=&nbsp;<span bind-to="theta"></span>°</div>
       <div class="pkmn-data-wide">Ψ&nbsp;=&nbsp;(<span bind-to="psiVec"></span>)</div>

+ 6 - 4
web/main.js

@@ -102,13 +102,13 @@ const calcScores = (data, target) => {
   const deltaVec = centroid.map((c, i) => c - target.vector[i]);
   const psiVec = stddev.map((s, i) => Math.hypot(s, deltaVec[i]));
   const psi = Math.hypot(...psiVec);
-  const theta = Math.acos(Math.min(1, vectorDot(tilt, target.unit))) * rad2deg;
+  const theta = Math.acos(Math.min(1, vectorDot(tilt, target.unit)));
   const deltaC = chromaMean - target.chroma;
   const deltaH = Math.abs(hue - target.hue) * rad2deg;
 
   return {
     ...data,
-    geoDiff: psi * theta,
+    arcDiff: psi * theta * 100,
 
     psi,
     psiVec,
@@ -117,7 +117,7 @@ const calcScores = (data, target) => {
     psiB: psiVec[2],
     psiC: Math.hypot(chromaDev, deltaC),
 
-    theta,
+    theta: theta * rad2deg,
 
     delta: Math.hypot(...deltaVec),
     deltaVec,
@@ -503,9 +503,11 @@ const model = {
       sortUseClusterProportion && (({ clusters }, i) => clusters[i].proportion),
       sortUseInvClusterProportion && (({ clusters }, i) => clusters[i].inverseProportion)
     );
+    const usingCluster =
+      sortUseBestCluster || sortUseClusterProportion || sortUseInvClusterProportion;
     const getSortScore = (scores, i) =>
       (sortUseWholeImage ? scores.total[metric] : 0) +
-      getSortScoreClusterFactors(scores, i);
+      (usingCluster ? getSortScoreClusterFactors(scores, i) : 0);
 
     Object.entries(metricScores).forEach(([name, scores]) => {
       objectiveValues[name] = getSortScore(scores, bestClusterIndices[name]);