Add fixed-pixel ROI padding, complementing bbox_expansion - #419
Open
animmosmith wants to merge 1 commit into
Open
Add fixed-pixel ROI padding, complementing bbox_expansion#419animmosmith wants to merge 1 commit into
animmosmith wants to merge 1 commit into
Conversation
Closes #418. bbox_expansion already lets a particle's bounding box be expanded before its ROI is cropped, but that expansion is fractional - it scales with each particle's own size. There was no way to add a fixed, consistent pixel margin regardless of particle size, e.g. to guarantee a small non-particle border around every ROI fed to the classifier (which is run on this same cropped ROI as the exported file), or for visual inspection/montage context. Adds a new pad_bbox() helper (fixed-pixel analogue of the existing expand_bbox()) and a pad parameter threaded through the same chain bbox_expansion already uses: extract_roi -> extract_particles -> statextract -> CalculateStats. pad is applied on top of bbox_expansion, so either, both, or neither can be used. Clamped to image bounds the same way.
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.
Summary
Closes #418.
bbox_expansion already lets a particle's bounding box be expanded before its ROI is cropped, but that expansion is fractional - it scales with each particle's own size. There was no way to add a fixed, consistent pixel margin regardless of particle size - e.g. to guarantee a small non-particle border around every ROI fed to the classifier (which runs on this same cropped ROI as the exported file), or for visual inspection/montage context.
Adds a new
pad_bbox()helper (fixed-pixel analogue of the existingexpand_bbox()) and apadparameter threaded through the same chainbbox_expansionalready uses:extract_roi->extract_particles->statextract->CalculateStats.padis applied on top ofbbox_expansion, so either, both, or neither can be used. Clamped to image bounds the same way.Version bumped to 2.16.23, ready to merge once the rest of the current chain is in.
Test plan
flake8 pyopiaclean.pytest -m "not slow and not training"): 36 passed.🤖 Generated with Claude Code