Skip to content
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

Resample RGB images in C++ #29453

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Jan 11, 2025

PR summary

Agg already has RGB resampling with output to RGBA builtin, so we just need to correctly wire up the corresponding templates. With this RGB resampling mode, we save the extra copy from RGB to RGBA in NumPy land that was required for the previous always-RGBA resampling.

With the example from #29434, this saves 800MB of peak memory usage, which actually works out to two copies of 10000x10000x4 bytes; I'm not sure where the second copy comes from.

While this does pass tests, I think there may be some room for further improvement, as the input to the C++ code is A[..., :3], which should be a discontiguous view, but then the pybind11 code forces it to be contiguous, which would make another copy. There are some offset and step settings in Agg that I think we can use to avoid this copy as well, but it might require extra template expansions.

PR checklist

Agg already has RGB resampling with output to RGBA builtin, so we just
need to correctly wire up the corresponding templates. With this RGB
resampling mode, we save the extra copy from RGB to RGBA in NumPy land
that was required for the previous always-RGBA resampling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant