i have a large array and want to place a smaller array at some offset and at the same time ignore zeros in the smaller array. what's the best way to do that?
I tried masked arrays but somehow this is slow
mask = np.ma.masked_equal(pixels, 0, False)
output[offset_y:offset_y+tile_height,offset_x:offset_x+tile_width] = np.where(mask.mask, output[offset_y:offset_y+tile_height,offset_x:offset_x+tile_width], pixels)
then i tried this
np.place(output[offset_y:offset_y+tile_height,offset_x:offset_x+tile_width], pixels>0, pixels[pixels>0])
but it is very slow
what is the fastest way to do so?