Thursday, 18 April 2019

Boundary modes in scipy.ndimage.laplace

The function scipy.ndimage.laplace can be used to calculate the Laplace operator applied to N-dimensional arrays. If one wants to use this function, for example, for applications in physics, the crucial part is often how to handle the boundaries.

Looking at the function documentation, a number of options are supported:

  • ‘reflect’ (d c b a | a b c d | d c b a)
  • ‘constant’ (k k k k | a b c d | k k k k)
  • ‘nearest’ (a a a a | a b c d | d d d d)
  • ‘mirror’ (d c b | a b c d | c b a)
  • ‘wrap’ (a b c d | a b c d | a b c d)

One thing I am personally missing is a 'smooth continuation' option. In the above notation, it would correspond to a slightly modified version of the mirror option:

  • 'smooth continuation' ((a-d) (a-c) (a-b) | a b c d | (d-c) (d-b) (d-a))

The motivation for this is to not introduce kinks at the boundary, which all of the supported options seem to be doing for an arbitrary input.

Question: Is there any way to do this Laplace operation in scipy/numpy?



from Boundary modes in scipy.ndimage.laplace

No comments:

Post a Comment