-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
downscale_local_mean with non-integer factors? #2827
Comments
Hi, thanks for reaching out. Even if your implementation is slow, this would be a useful option. I would integrate it into the existing |
Yes, it works in N dimensions. It's written as a sequence of matrix multiplications, one along each axis. |
Sounds great, looking forward to a pull request with the feature! |
This has actually been requested before, so thanks for contributing! |
Do you have any guidance on the appropriate API here? This breaks at least two aspects of the API for
Also, we can just as easily do upscaling with the local mean value as well downscaling, e.g., resizing My initial thought was to make My tentative proposal would be a new function, perhaps |
A new function resize_local_mean (maybe rather rescale_local_mean to match the semantics of the existing resize/rescale functions) sounds like a good proposal to me. Potentially, we want to deprecate the old function and merge it into this new function. For this we would probably have to introduce some parameter, eg mode=“cut|pad” and the cval parameter for the pad mode. What do you think? Let’s hear some feedback on that from other people as well.
Whenever the input is exactly divisible by integer factors, we could internally also fall back to the old implementation, assuming it was significantly faster?
|
I think the old behavior is somewhat broken. We should definitely transition to @shoyer's implementation eventually. Suggested route: set For now, let's include the function in See also http://scikit-image.org/docs/dev/contribute.html#deprecation-cycle |
@shoyer Would you mind sharing your current implementation? I'm having trouble deriving an analytical expression for the weights of each voxel. |
See https://gist.github.com/shoyer/c0f1ddf409667650a076c058f9a17276 for the version I wrote for my needs. |
@shoyer Thanks a lot! |
I'm interested in a version of
skimage.transform.downscale_local_mean()
which handles non-evenly dividing factors without padding the image. I want each pixel in the result to be an weighted average of overlapping pixels in the source, with weights equal to the area of overlap.To be more explicit, this transformation is linear along equal axis. For example, from size 5 to size 2, it can be written as the matrix:
This is actually what I expected
skimage.transform.resize()
to do, before I noticed the docstring warning about anti-aliasing.Would this be a welcome addition to scikit-image in some form? I wrote a version that works for my own purposes, but my guess is that it's too slow for skimage, since I use a dense matrix multiply along each axis with matrix of weights.
The text was updated successfully, but these errors were encountered: