Skip to content

Automatically shrink reconstruction volume #2221

Draft
hrobarts wants to merge 4 commits intomasterfrom
shrink_volume
Draft

Automatically shrink reconstruction volume #2221
hrobarts wants to merge 4 commits intomasterfrom
shrink_volume

Conversation

@hrobarts
Copy link
Contributor

@hrobarts hrobarts commented Oct 10, 2025

Changes

Code to reduce the reconstruction volume

  • Performs a quick binned reconstruction and applies a circular mask (maybe this should be optional)
  • If auto=True, tries to automatically find the limits for the reduced reconstruction
  • Set a threshold between data and background or use an Otsu filter
  • Plots the maximum pixel intensity along each direction, finds pixels above the threshold, identifies large connected components and calculates limits around them
  • Can apply a buffer around the automatically calculated limits
  • If manual_limits are set these over-ride the automatically calculated limits

vs = VolumeShrinker()
ig_reduced = vs.run(data, auto=True)

image

ig_reduced = vs.run(data, auto=True, buffer=10)
image

Use manual limits in specified direction
image

Don't reduce in specified directions
vs = VolumeShrinker()
ig_reduced = vs.run(data, auto=True, buffer=10, manual_limits={'horizontal_x':None, 'horizontal_y':None})
image

If logging is enabled, plot a histogram with the threshold and reduced box
image

Testing you performed

Please add any demo scripts to https://github.com/TomographicImaging/CIL-Demos/tree/main/misc

Related issues/links

May close #1998

Checklist

  • I have performed a self-review of my code
  • I have added docstrings in line with the guidance in the developer guide
  • I have updated the relevant documentation
  • I have implemented unit tests that cover any new or modified functionality
  • CHANGELOG.md has been updated with any functionality change
  • Request review from all relevant developers

@hrobarts hrobarts linked an issue Oct 29, 2025 that may be closed by this pull request
@hrobarts hrobarts self-assigned this Nov 3, 2025
@hrobarts
Copy link
Contributor Author

hrobarts commented Dec 2, 2025

For discussion:

Could this be a method on image_data

  • The user would have to reconstruct their data themselves before calling the get reduced image geometry method
  • Once they have reconstructed the full thing they might not be interested in reducing the volume
  • If they bin the data they will have to convert the binned reduced geometry to their unbinned reduced geometry

Could this be a method on acquisition_geometry

  • The method needs access to the data so would have to pass the data as an argument?
  • Similar to the ag.get_ImageGeometry() method we could have ag.get_reduced_ImageGeometry(data)

Could this be a method on acqusition_data

  • Makes the most sense, but confusing get_ImageGeometry is a method on acquisition_geometry and this would be a method on acqusition_data. Could allow both?

@hrobarts
Copy link
Contributor Author

hrobarts commented Dec 2, 2025

What should the name be

  • get_reduced_ImageGeometry()
  • get_optimal_ImageGeometry() - makes more sense if we also do rotation at some point
  • get_shrunk_ImageGeometry()
    or
    get_ImageGeometry() with argument method=auto (or rotate in future?) or enums like in labels

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.

Add tool for auto-cropping Image Geometry

1 participant