imagej / imagej/ImageJ

ImageStack.getRoi() inconsistent behaviour

Open
#247 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
786
Forks
267
PR merge metrics
No merged PRs in 30d

Description

```
final Rectangle r = stack.getRoi();
```
Used to give a `Rectangle` either of the bounds of the ROI if one was set or with the dimensions and origin of the whole image.

You could then use `r.x` or `r.width` regardless of whether there was an ROI or not, to scan pixels inside the ROI (if one was set) or the whole image (if no ROI was set).

Recently this broke so that this behaviour was not maintained leading to legacy code not working any more.

I fixed this for BoneJ's Slice Geometry by using `ImagePlus.getRoi().getBounds()` instead of the `ImageStack`-based methods.
https://github.com/bonej-org/BoneJ2/pull/346/commits/8e9141951418906cd68f4a9b6de5ba609f63cbc7

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting ImageStack.getRoi() and the related ImagePlus.getRoi().getBounds() behavior. Compare results with and without an ROI, then add or update a regression test showing that the returned Rectangle covers the ROI or the full image as appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
computer-vision
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.