Skip to content

fix resize interpolation contract adherence#24

Merged
bghira merged 1 commit intomainfrom
bugfix/resize-interpolation
Apr 6, 2026
Merged

fix resize interpolation contract adherence#24
bghira merged 1 commit intomainfrom
bugfix/resize-interpolation

Conversation

@bghira
Copy link
Copy Markdown
Owner

@bghira bghira commented Apr 6, 2026

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:

  • Refactored the OpenCVBatchProcessor to 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]
  • Updated the resize_bilinear_opencv and resize_lanczos4_opencv functions to explicitly pass the correct interpolation method to the underlying resizing implementation. (src/opencv_ops.rs, [1] [2]

Performance and Python bindings:

  • Optimized the batch_calculate_luminance Python binding by using Rayon for parallel computation, improving performance when processing multiple images. (src/python_bindings.rs, src/python_bindings.rsL955-R968)

Testing enhancements:

  • Added a new test to verify that bilinear and Lanczos4 resizing use different OpenCV interpolation modes, and that both single and batch resizing paths produce consistent results. Also updated imports in the test module for clarity. (src/tests.rs, [1] [2]

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_LINEAR and adding a Lanczos4 batch path.
  • Updates the single-image OpenCV resize wrappers to pass the correct interpolation constants.
  • Parallelizes batch_calculate_luminance in 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.

Comment thread src/python_bindings.rs
@bghira bghira merged commit 5f8d308 into main Apr 6, 2026
14 checks passed
@bghira bghira deleted the bugfix/resize-interpolation branch April 6, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants