From d8d28dc0385c5340af894a2fc3f4700e61cbf65f Mon Sep 17 00:00:00 2001
From: Jake Read <jake.read@cba.mit.edu>
Date: Sat, 16 Nov 2019 16:46:41 -0500
Subject: [PATCH] going to shunt to grayscale

---
 hunks/adhoc/correlate.js                |  7 +++++--
 save/contexts/cuttlefish/correlate.json | 22 +++++++++++++++++++---
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/hunks/adhoc/correlate.js b/hunks/adhoc/correlate.js
index e5a734a..cf80e1b 100644
--- a/hunks/adhoc/correlate.js
+++ b/hunks/adhoc/correlate.js
@@ -23,8 +23,9 @@ let correlate = (a, b, x, y) => {
   for(let i = 0; i < a.data.length; i ++){
     sumA += a.data[i]
 
-    bi = y * b.width + x
-    bi += Math.floor(i / a.width) * b.width + i
+    // something is up w/ this feer sure
+    bi = (y * b.width + x) * 4
+    bi += Math.floor(i / (a.width * 4)) * (b.width * 4) + i
     sumB += b.data[bi]
 
     sumDot += a.data[i] * b.data[bi]
@@ -91,6 +92,8 @@ export default function Correlate(){
   let resOut = this.output('ImageData', 'correlation')
 
   let canvasA = $('<canvas>').get(0)
+  canvasA.width = 50
+  canvasA.height = 50
   let ctxA = canvasA.getContext('2d')
   ctxA.width = 50
   ctxA.height = 50
diff --git a/save/contexts/cuttlefish/correlate.json b/save/contexts/cuttlefish/correlate.json
index 8e3bb97..e68e608 100644
--- a/save/contexts/cuttlefish/correlate.json
+++ b/save/contexts/cuttlefish/correlate.json
@@ -55,16 +55,26 @@
           "type": "ImageData",
           "connections": [
             {
-              "inHunkIndex": "3",
+              "inHunkIndex": "4",
               "inHunkInput": "0"
             }
           ]
         }
       ]
     },
+    {
+      "type": "image/displayimagedata",
+      "name": "image/displayimagedata_4",
+      "inputs": [
+        {
+          "name": "image",
+          "type": "ImageData"
+        }
+      ]
+    },
     {
       "type": "adhoc/correlate",
-      "name": "adhoc/correlate_3",
+      "name": "adhoc/correlate_5",
       "inputs": [
         {
           "name": "frame",
@@ -74,7 +84,13 @@
       "outputs": [
         {
           "name": "correlation",
-          "type": "ImageData"
+          "type": "ImageData",
+          "connections": [
+            {
+              "inHunkIndex": "3",
+              "inHunkInput": "0"
+            }
+          ]
         }
       ]
     }
-- 
GitLab