imagej / imagej/imagej-ops

Matching issues with create.kernel op

Open
#545 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
94
Forks
44
PR merge metrics
No merged PRs in 30d

Description

The following Groovy script:

```groovy
#@ OpService ops

ops.run("create.kernel", [[1,2,3], [4,5,6], [7,8,9]] as double[][])
```

throws:

```text
java.lang.IllegalArgumentException: No matching 'create.kernel' op

Request:
- create.kernel(
double[],
double[],
double[])

Candidates:
1. (RandomAccessibleInterval out) =
net.imagej.ops.create.kernel.CreateKernel2D(
double[][] in,
ComplexType type?)
Too many arguments: 3 > 2
```

Trying to explicitly cast `as Object[]` doesn't work either.

---

When running:

```groovy
ops.create().kernel([[0,1,0],[1,-4,1],[0,1,0]] as double[][])
```

instead, we get:

```text
Request:
- net.imagej.ops.Ops$Create$Img/net.imagej.ops.special.function.UnaryFunctionOp(
Interval,
null)

Candidates:
1. (Img out) =
net.imagej.ops.create.img.CreateImgFromImg(
Img in)
Too many arguments: 2 > 1
2. (Img out) =
net.imagej.ops.create.img.CreateImgFromII(
IterableInterval in)
Too many arguments: 2 > 1
3. (Img out) =
net.imagej.ops.create.img.CreateImgFromRAI(
RandomAccessibleInterval in)
Too many arguments: 2 > 1
4. (Img out) =
net.imagej.ops.create.img.CreateImgFromDimsAndType(
Dimensions in1,
==> NativeType in2,
ImgFactory factory?)
Missing required argument
5. (Img out) =
net.imagej.ops.create.img.CreateImgFromInterval(
Interval in)
Too many arguments: 2 > 1
```

---

To get it work correctly, you currently have to provide the target type like this:

```groovy
#@ OpService ops

import net.imglib2.type.numeric.real.FloatType

ops.run("create.kernel", [[1,2,3], [4,5,6], [7,8,9]] as double[][], new FloatType())
```

or, directly use [`net.imglib2.img.array.ArrayImgs`](http://javadoc.scijava.org/ImgLib2/index.html?net/imglib2/img/array/ArrayImgs.html) instead.

---

See [this discussion on gitter](https://gitter.im/imagej/imagej-ops?at=5aa50c80c3c5f8b90d5b185c).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the `ops.run("create.kernel", ...)` and `ops.create().kernel(...)` entry points, then inspect the `CreateKernel2D` and `CreateImgFrom...` candidates named in the errors. Reproduce both calls and compare their operation matching behavior. Done means the reported kernel invocation resolves correctly without requiring the explicit target type, with coverage for the failing forms.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.