Skip to content
Snippets Groups Projects
Commit 4fee2244 authored by Jake Read's avatar Jake Read
Browse files

stash correlate and attempt to go for color

parent 2a9d5c26
Branches
No related tags found
No related merge requests found
...@@ -20,7 +20,6 @@ let correlate = (a, b, x, y) => { ...@@ -20,7 +20,6 @@ let correlate = (a, b, x, y) => {
let sumA = 0 let sumA = 0
let sumB = 0 let sumB = 0
let sumDot = 0 let sumDot = 0
let bi = 0
// i will be index within the flat-af array under a, // i will be index within the flat-af array under a,
for(let i = 0; i < a.length; i ++){ for(let i = 0; i < a.length; i ++){
for(let j = 0; j < a[0].length; j ++){ for(let j = 0; j < a[0].length; j ++){
...@@ -29,36 +28,8 @@ let correlate = (a, b, x, y) => { ...@@ -29,36 +28,8 @@ let correlate = (a, b, x, y) => {
sumDot += a[i][j] * b[i + x][j + y] sumDot += a[i][j] * b[i + x][j + y]
} }
} }
return sumDot / Math.sqrt(sumA * sumA * sumB * sumB) // I'm still not convinced this is a really great filter
return sumDot / Math.sqrt((sumB * sumB)*(sumA * sumA))
/*
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
} }
let delay = (time) => { let delay = (time) => {
...@@ -137,7 +108,7 @@ async function run(a, b){ ...@@ -137,7 +108,7 @@ async function run(a, b){
imdBuffer[lc ++] = dt imdBuffer[lc ++] = dt
imdBuffer[lc ++] = dt imdBuffer[lc ++] = dt
imdBuffer[lc ++] = dt imdBuffer[lc ++] = dt
imdBuffer[lc ++] = dt imdBuffer[lc ++] = 255
} }
} }
let imgRes = new ImageData(imdBuffer, resX, resY) let imgRes = new ImageData(imdBuffer, resX, resY)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment