Could you make this work for either a 2D image or a ND array? Just thinking that it could have wider use to be able to do both. You could have a optional `axis` kwarg that will default to `[0,1]` for (x,y) ?