imagej / imagej-ops

ImageJ Ops: "Write once, run anywhere" image processing
https://imagej.net/libs/imagej-ops
BSD 2-Clause "Simplified" License
88 stars 42 forks source link

DefaultGaussRAI.compute() reports cryptic IAE for sigma dimension mismatch #646

Open gselzer opened 2 years ago

gselzer commented 2 years ago

As reported in this zulip chat, we get a cryptic IllegalArgumentException when we call DefaultGaussRAI.compute() with a sigmas whose length does not match the input dimensionality. We should try our best to mitigate or fix this.

Here are my suggestions for fixes.

But, there is a third option: using Contingent! We can't use this when porting the fix to ImageJ Ops2, but it could help avoid the issue in this project.

ctrueden commented 2 years ago

I suggest not using Contingent, because it will be replacing one cryptic error message with a different cryptic error message (no matching ops). I favor doing a length check and throwing IllegalArgumentException if it doesn't match. And also: if an array of length 1 is passed, expand it to an array of length N with all equal values.