Repository navigation
Integrate synimage module into openpiv.tools for easy synthetic image generation - #349
Merged
Merged
Conversation
Copilot
AI
changed the title
[WIP] Add synimage integration into openpiv.tools
Integrate synimage module into openpiv.tools for easy synthetic image generation
Oct 22, 2025
Co-authored-by: alexlib <747110+alexlib@users.noreply.github.com>
alexlib
force-pushed
the
copilot/add-synimage-integration
branch
from
November 14, 2026 17:19
fcce15a to
d82017f
Compare
alexlib
marked this pull request as ready for review
November 14, 2026 17:19
|
Sorry @alexlib, your pull request is larger than the review limit of 150,000 diff characters |
There was a problem hiding this comment.
🟡 Changes recommended
The default synthetic motion exceeds the advertised PIV workflow’s recoverable displacement range, preventing correct recovery, while additional pixel-range, empty-frame, and interpolation defects remain unresolved.
5 open issues
What changed in this PR
This PR incorporates synthetic PIV image generation into OpenPIV’s package structure, exposing it through from openpiv.tools import synimage for testing and validation workflows.
Changes:
- Packages the existing flow-field and particle-rendering utilities under
openpiv.synimage. - Adds a
synimagegen()convenience function for generating image pairs with configurable parameters. - Adds seven tests covering imports, image generation, and underlying utilities.
| File | Description |
|---|---|
openpiv/tools.py |
Exposes the synimage module through the tools API. |
openpiv/test/test_synimage.py |
Adds synthetic-image API and output checks. |
openpiv/synimage/test_synimagegen.py.bck |
Includes a backup of particle-rendering tests. |
openpiv/synimage/synimagegen.py |
Houses flow-field, particle-generation, and rendering utilities. |
openpiv/synimage/__init__.py |
Exports utilities and adds the image-pair convenience wrapper. |
Review effort: Balanced
|
|
||
| def synimagegen( | ||
| image_size=128, | ||
| dt=0.1, |
Comment on lines
+36
to
+37
| self.f_U = scipy.interpolate.RectBivariateSpline(data[:, 0], data[:, 1], data[:, 2]) | ||
| self.f_V = scipy.interpolate.RectBivariateSpline(data[:, 0], data[:, 1], data[:, 3]) |
| x_bound, | ||
| y_bound, | ||
| image_size, | ||
| path="None", |
Comment on lines
+263
to
+276
| bounded_xy_1 = np.asarray( | ||
| [ | ||
| xy | ||
| for xy in xy_1 | ||
| if x_bound[1] >= xy[0] >= x_bound[0] and y_bound[1] >= xy[1] >= y_bound[0] | ||
| ] | ||
| ) | ||
| bounded_xy_2 = np.asarray( | ||
| [ | ||
| xy | ||
| for xy in xy_2 | ||
| if x_bound[1] >= xy[0] >= x_bound[0] and y_bound[1] >= xy[1] >= y_bound[0] | ||
| ] | ||
| ) |
| noise_mean = 2 ** (bit_depth * 0.3) | ||
| noise_std = 0.25 * noise_mean | ||
| noise = noise_std * np.random.randn(height, width) + noise_mean | ||
| return (image_out * (2**bit_depth * 2.8**2 / 8) + noise).astype(int)[::-1] No newline at end of file |
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.


Overview
This PR integrates the existing
synimagemodule into theopenpiv.toolspackage, making it easily accessible for users who need to generate synthetic PIV images for testing and validation purposes.Changes
Module Integration
synimagedirectory intoopenpiv/synimage/to make it part of the main package structureopenpiv/synimage/__init__.pyto expose the module's functionalityopenpiv/tools.pyto make synimage accessible viafrom openpiv.tools import synimageNew Convenience Function
Added a
synimagegen()wrapper function that provides an easy-to-use interface for generating synthetic PIV images with sensible defaults:Testing
openpiv/test/test_synimage.pywith 7 test cases covering:Benefits
Testing Results
Usage Example
This makes the workflow more streamlined for users who want to test or validate their PIV configurations before processing real experimental data.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.