Add automatic image resizing based on max_pixels threshold#27
Open
adamjtaylor wants to merge 3 commits into
Open
Add automatic image resizing based on max_pixels threshold#27adamjtaylor wants to merge 3 commits into
adamjtaylor wants to merge 3 commits into
Conversation
- Implemented resize_if_needed() function to automatically downsample images exceeding max_pixels - Calculates scaling factor using sqrt(max_pixels/current_pixels) to preserve aspect ratio - Handles multi-channel data by resizing each channel separately - Uses bilinear interpolation with anti-aliasing to prevent artifacts - Provides user feedback via print statements when resizing occurs - Updated remove_background() and keep_background() to handle both zarr and numpy arrays - Added comprehensive test suite covering various scenarios - Exported resize_if_needed in package __init__.py Fixes #25 Co-authored-by: Adam Taylor <adamjtaylor@users.noreply.github.com>
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
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 adds a new utility function for automatic image resizing and integrates it into the image processing workflow. It also improves robustness by ensuring consistent handling of array types and adds comprehensive tests for the new resizing functionality.
New image resizing functionality:
resize_if_neededincore.pyto automatically downsample multi-channel images if they exceed a specifiedmax_pixelsthreshold, preserving aspect ratio and data type. This function is now imported and included in the module's public API (__init__.py). [1] [2] [3]resize_if_neededinto the main processing workflow to ensure that images are resized before further processing or saving, preventing memory issues with large images.Robustness and consistency improvements:
remove_backgroundandkeep_backgroundfunctions to accept bothzarr.Arrayandnp.ndarrayinputs, ensuring they always operate on a numpy array internally for consistency.resizefromskimage.transformto support the new resizing functionality.Testing:
resize_if_neededto verify correct behavior when resizing is not needed, when within limits, when resizing is required, and to ensure aspect ratio and data type are preserved.