It's past midnight, and maybe someone has an idea how to solve my problem. I want to count the number of neighboring cells (which means the number of fields in the array with other values, for example, zeros in the neighborhood of the array values) as the sum for each valid value! .
Example:
import numpy, scipy s = ndimage.generate_binary_structure(2,2)
How can I count the number of zeros this way if the structure of my values โโchanges? For some reason, I believe that I should use the SciPy binary_dilation function, which can increase the structure of values, but a simple calculation of overlaps cannot lead me to the correct amount or do it?
print ndimage.binary_dilation(a,s).astype(a.dtype) [[0 0 0 0 0 0] [0 1 1 1 1 1] [0 1 1 1 1 1] [0 1 1 1 1 1] [0 1 1 1 1 0] [0 0 0 0 0 0]]
source share