From 4fee22444dab8a5704b03cdd95bc8c7c6e574e0d Mon Sep 17 00:00:00 2001 From: Jake Read <jake.read@cba.mit.edu> Date: Sun, 17 Nov 2019 12:50:42 -0500 Subject: [PATCH] stash correlate and attempt to go for color --- hunks/adhoc/correlate.js | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/hunks/adhoc/correlate.js b/hunks/adhoc/correlate.js index 1dd1995..ecc5965 100644 --- a/hunks/adhoc/correlate.js +++ b/hunks/adhoc/correlate.js @@ -20,7 +20,6 @@ let correlate = (a, b, x, y) => { let sumA = 0 let sumB = 0 let sumDot = 0 - let bi = 0 // i will be index within the flat-af array under a, for(let i = 0; i < a.length; i ++){ for(let j = 0; j < a[0].length; j ++){ @@ -29,36 +28,8 @@ let correlate = (a, b, x, y) => { sumDot += a[i][j] * b[i + x][j + y] } } - return sumDot / Math.sqrt(sumA * sumA * sumB * sumB) - - /* - for(let i = 0; i < a.data.length; i ++){ - sumA += a.data[i] - // to find the reciprocal pixel in b, - // we can start at the top-left corner: here is the 'i_th' element - // within b, correspondign to the XY of the top-left of a, - bi = (y * b.width * 4) + x * 4 - // to get down from here, the row of a this i is in: - let rca = Math.floor(i / a.width * 4) - bi += rca * b.width * 4 - // and the increment, - bi += (i % (b.width * 4)) - // ok ? - if(bi >= b.data.length){ - bi = b.data.length - // happens all the time, go home do this tomorrow - console.log('yep', bi, rca, i, x, y) - //throw new Error('halting') - } - sumB += b.data[bi] - - sumDot += a.data[i] * b.data[bi] - } - */ - //return 55 //(sumDot / Math.sqrt(sumA*sumA + sumB*sumB)) - // a, b are str8 up matricies - //console.log(b.width) - // ok, now we can do the maths on a and b, thx + // I'm still not convinced this is a really great filter + return sumDot / Math.sqrt((sumB * sumB)*(sumA * sumA)) } let delay = (time) => { @@ -137,7 +108,7 @@ async function run(a, b){ imdBuffer[lc ++] = dt imdBuffer[lc ++] = dt imdBuffer[lc ++] = dt - imdBuffer[lc ++] = dt + imdBuffer[lc ++] = 255 } } let imgRes = new ImageData(imdBuffer, resX, resY) -- GitLab