[Solved] how to change the particuler elements of an array
You can use a 2D convolution on the 1s with a 3×3 kernel of 1s to identify the centers of the 3×3 squares, then dilate them and restore the non 1 numbers from scipy.signal import convolve2d from scipy.ndimage import binary_dilation # get 1s (as boolean) m = data==1 kernel = np.ones((3, 3)) # get centers … Read more