I have 2D numpy arrays and a center with some coordinates (i, j) (coordinates mean row and column). I need to sum
up all array elements at the same distance from the center (simple
euklidean distance) for each possible distance from 0 to the edge of the image, i.e. result is an 1D array where the 0th element gives the sum of pixels in distance 0 from center (i.e. just the center), 1st element is the sum of all pixels at distance 1 pixel and so on.
My feeling is that this should be possible to do without a for loop,
but unfortunately I don’t know enough matrix python tricks to figure
this out.
Thank you very much!
You can use
np.bincount…And
resultis an array withresult[distance]giving sum over all values with smaller or equal distances.