I have a 2D generalization of scipy.signal.savgol_filter
. The call signature would be something like this:
savgol2d_filter(
a: np.ndarray, window_radius: float, polyorder: int, axes=(-2, -1),
mode='constant', circular=True, cval=0.0, conv_method='auto'
) -> np.ndarray
Differences with the existing 1D version:
- With
circular=True
, it takes samples from a disc rather than from a square. For example,window_radius=2.5, polyorder=2
will result in a 5x5 kernel with 21 nonzero elements. - The polynomial has terms
x**i * y**j
withi+j <= polyorder
. - I wouldn’t support
mode='interpolate'
because that’s a lot of book-keeping and handling of edge cases for 2D data. conv_method
will be passed toscipy.signal.convolve
.deriv=True
would not be supported (I don’t think it makes much sense for 2D data).
I have an implementation for polyorder=2 and without the mode selector. I can rework it for the above interface. Shall I proceed to do this and create a PR?
(I have another topic in this forum about interpolation methods; that’s a long-term project. The above is probably a better way for me to get familiar with scipy development.)