imagej / imagej/imagej-ops

Map namespace methods type safety

Open
#612 1 comment 0 reactions 0 assignees View on GitHub
bug matching
Dominant language
Java
Stars
94
Forks
44
PR merge metrics
No merged PRs in 30d

Description

When I was trying to copy an image converted with LUT to a freshly created `Img`, the following happens:
```java
RandomAccessibleInterval floatImg = ArrayImgs.floats(128, 128);
RandomAccessibleInterval argbRAI = Converters.convert(floatImg, new RealLUTConverter(0, 1, ColorTables.GRAYS), new ARGBType());
Img argbImg = ArrayImgs.argbs(128, 128);
ops.copy().rai(argbImg, argbRAI);
```
Output:
```
net.imglib2.converter.read.ConvertedRandomAccessibleInterval cannot be cast to net.imglib2.IterableInterval

java.lang.ClassCastException: net.imglib2.converter.read.ConvertedRandomAccessibleInterval cannot be cast to net.imglib2.IterableInterval
at net.imagej.ops.map.MapUnaryComputers$IIToIIParallel.compute(MapUnaryComputers.java:87)
at net.imagej.ops.copy.CopyRAI.compute(CopyRAI.java:90)
at net.imagej.ops.copy.CopyRAI.compute(CopyRAI.java:54)
at net.imagej.ops.special.hybrid.UnaryHybridCF.run(UnaryHybridCF.java:75)
at net.imagej.ops.special.hybrid.UnaryHybridCF.run(UnaryHybridCF.java:97)
at org.scijava.command.CommandModule.run(CommandModule.java:199)
at net.imagej.ops.OpEnvironment.run(OpEnvironment.java:950)
at net.imagej.ops.OpEnvironment.run(OpEnvironment.java:157)
at net.imagej.ops.copy.CopyNamespace.rai(CopyNamespace.java:167)
...
```
The cause seems to me that while matching ops, a `ConvertedRandomAccessibleInterval` is recognized as directly convertible to an `II` in `DefaultOpMatchingService.canConvert()` and this leads the op service to believe that `IIToIIParallel` is a suitable op for the task. I haven't dug deeper than that. Any insights?

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the Java example and begin with the stack trace at MapUnaryComputers.java:87 and CopyRAI.java:90. Then inspect DefaultOpMatchingService.canConvert() and the IIToIIParallel selection to determine why ConvertedRandomAccessibleInterval is accepted as an IterableInterval. Done means the copy operation selects a valid implementation and completes without the reported ClassCastException.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.