Say I have a numpy array a
, and I want to create a new array, b
such that
b[i, j]
is a function of, say:
a[i-1, j-1], a[i-1, j ], a[i-1, j+1],
a[i , j-1], a[i , j ], a[i , j+1],
a[i+1, j-1], a[i+1, j ], a[i+1, j+1]
What would be the fastest way to do this?
As this is a separable filter, is there any way to run this in multiple threads? (not processes, because I would have to copy the data back)
Or is writing C code to bypass the GIL mandatory?
Partial solutions (like assuming the function is linear) are welcome too.