question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding equivalent filters from scipy.ndimage.filters

See original GitHub issue

Would be great to support some common filters from scipy.ndimage.filters. Having convolve, correlate and generic_filter would be great and allow users to build up many common convolutions with relatively little work using a familiar API. There are others that would be very nice as well.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:17 (17 by maintainers)

github_iconTop GitHub Comments

4reactions
grlee77commented, Mar 19, 2019

Hi @jakirkham. Do you have an immediate need for this or a particular use case in mind?

I recently implemented the equivalent of ndi.convolve (built using a GPU-based implementation of scipy.signal.upfirdn(..., up=1, down=1) under the hood) that supports float32, float64, complex64 and complex128. I haven’t tried to make a PR for it here or posted it publicly, but can share it if you are interested in collaborating on it.

I implemented scipy.signal.upfirdn using CuPy and added support for various signal extension modes at the boundary (not currently available in SciPy’s upfirdn). In my case, I started implementing a library expanding the functionality in PyWavelets. The version of upfirdn I have currently only supports downsampled convolution with up=1, down=M or upsampled convolution with up=M, down=1 as those were the only cases I needed for M-band wavelet filterbanks. With a bit more effort, it could be updated to allow the general setting of any positive integer up, down and become suitable for a PR here.

2reactions
grlee77commented, Mar 12, 2020

I finally got around to cleaning things up and making a public repo for some of the things I mentioned about a year ago (better late than never!). A CPU + GPU implementation of upfirdn is in the fast_upfirdn package. It differs from the implementation in cusignal in that the GPU implementation uses cupy.RawKernel instead of Numba.

Building on top of this, cupyimg implements a ton of other functions, primarily from scipy.ndimage, scipy.signal and scikit-image.

I have been working on getting some scipy.ndimage and NumPy stuff that was needed implemented as PRs here so that they can benefit from better code review and CI testing. Currently cupyimg does not have CI and I have just been running tests locally on linux. There are quite a few tests copied from the corresponding CPU-based packages, but these do not typically conform to the CuPy style, so getting things ready for PR here would still require quite a bit of work. There is also a substantial amount of kernel code duplication that could be avoided by refactoring of the type done by @coderforlife in #3184.

I think scikit-image functions are out of scope for CuPy itself. I’m not too sure about the viability of maintaining a parallel fork long-term without obtaining any official funding/support to do so, but wanted to try out at least a subset of the library that is built on top of scipy.ndimage functions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

scipy.ndimage.gaussian_filter — SciPy v1.9.3 Manual
The standard deviations of the Gaussian filter are given for each axis as a sequence, or as a single number, in which case...
Read more >
Custom filter with scipy ndimage - python - Stack Overflow
I need a filter that, given a structural element located at pixel i,j, it assigns a value of that pixel to all other...
Read more >
2.6. Image manipulation and processing using Numpy and Scipy
scipy : scipy.ndimage submodule dedicated to image processing (n-dimensional ... Image filtering: denoising, sharpening; Image segmentation: labeling pixels ...
Read more >
Module: filters — skimage v0.19.2 docs
See scipy.ndimage.correlate for a description of cross-correlation. ... Frequency and orientation representations of the Gabor filter are similar to those ...
Read more >
Multidimensional image processing (cupyx.scipy.ndimage)
correlate1d (input, weights[, axis, output, ...]) One-dimensional correlate. ; gaussian_filter (input, sigma[, order, ...]) Multi-dimensional Gaussian filter.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found