Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes OpenCV resize interpolation behavior explicit (so “bilinear” and “Lanczos4” paths actually use the correct OpenCV interpolation modes), adds a regression test for that contract, and parallelizes the Python batch luminance binding.
Changes:
- Refactors OpenCV resize internals to accept an explicit interpolation mode, defaulting batch image resize to
INTER_LINEARand adding a Lanczos4 batch path. - Updates the single-image OpenCV resize wrappers to pass the correct interpolation constants.
- Parallelizes
batch_calculate_luminancein Python bindings using Rayon (with the GIL released) and adds an OpenCV interpolation contract test.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/opencv_ops.rs | Makes interpolation explicit for single and batch OpenCV resizing; fixes bilinear/Lanczos4 wrappers to use correct modes. |
| src/python_bindings.rs | Parallelizes batch luminance calculation using Rayon and py.allow_threads. |
| src/tests.rs | Adds a regression test ensuring bilinear vs Lanczos4 produce different results and that batch vs single paths match. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors and improves the image resizing functionality using OpenCV, making interpolation methods explicit and configurable for both single and batch image resizing operations. It also optimizes the Python binding for batch luminance calculation by parallelizing the computation. Additional tests are added to ensure correct behavior of the new interpolation logic.
OpenCV image resizing improvements:
OpenCVBatchProcessorto allow specifying the interpolation method (e.g.,INTER_LINEAR,INTER_LANCZOS4) for both single and batch image resizing. This makes the resizing behavior explicit and configurable. (src/opencv_ops.rs, [1] [2] [3] [4] [5] [6]resize_bilinear_opencvandresize_lanczos4_opencvfunctions to explicitly pass the correct interpolation method to the underlying resizing implementation. (src/opencv_ops.rs, [1] [2]Performance and Python bindings:
batch_calculate_luminancePython binding by using Rayon for parallel computation, improving performance when processing multiple images. (src/python_bindings.rs, src/python_bindings.rsL955-R968)Testing enhancements:
src/tests.rs, [1] [2]