SobelRAI derivativeComputer array error prone if dimension mismatch
- Dominant language
- Java
- Stars
- 94
- Forks
- 44
- PR merge metrics
- No merged PRs in 30d
Description
As I discovered by trying to solve a [post on forum.image.sc](https://forum.image.sc/t/slice-wise-sobel-using-ops/38720), `SobelRAI` can throw `ArrayIndexOutOfBoundsException`s if the input image differs on the number of dimensions from what was passed to the matcher during the creation of the Op. The faulty line is [here](https://github.com/imagej/imagej-ops/blob/b120cd7dea3433000916a3a58a0daf78dd8ff895/src/main/java/net/imagej/ops/filter/sobel/SobelRAI.java#L88): if the input image has fewer dimensions than the image passed during creation, we will receive an `ArrayIndexOutOfBoundsException` in that `for` loop, and if we have more dimensions than we had during Op creation, then not all dimensions of the image will be processed.
Is there any reason that we do not run a `for` loop on all dimensions of the image and use only one `derivativeComputer`? We could just transform the dimensions of the image to compute every dimension...
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/main/java/net/imagej/ops/filter/sobel/SobelRAI.java at the loop around line 88, and inspect how the matcher-created derivativeComputer relates to the input image dimensions. Reproduce inputs with fewer and more dimensions than the matcher, then verify that processing avoids index errors and covers every input dimension.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100